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


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

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>