Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS id vs class

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #235197
    k1n64r7hur
    Participant

    I am attempting to make a copyleft symbol however my normal procedure of using a class does not work whereas using an id does. I am wondering why the class does not work.

    Class http://codepen.io/k1n64r7hur/pen/NGVEBv
    ID http://codepen.io/k1n64r7hur/pen/OyYawW

    #235199
    Alen
    Participant

    @k1n64r7hur It’s because there’s no footer element with class of .copyleft

    footer.copyleft {}
    
    

    Would target.

    <footer class="copyleft"></footer>
    

    You can just use .copyleft in your CSS. The copy text is contained within a span element with the class of .copyleft so it would be span.copyleft {}.

    Hope that helps
    Alen

    #235200
    Alen
    Participant

    Looking at your other question…

    You should avoid targeting base html elements, ex footer.classunless you have a very good reason.

    If you’re interested in scoping try defining a parent class. I’ve forked your Pen

    http://codepen.io/alenabdula/pen/vNwvVW

    See when you use the just .class for all intents and purposes it doesn’t matter what element you attach the class it will still behave as expected.


    .parent {} .parent .child {} .parent .menu {}
    <div class="parent">
        <div class="child"></div>
        <ul class="menu">
                <li>List Item</li>
        </ul>
    </div>
    
    #235203
    k1n64r7hur
    Participant

    That makes sense, thanks.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.