Forums

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

Home Forums CSS id vs class Reply To: id vs class

#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>