Jump to content

.menu vs. #menu


owosso
 Share

Recommended Posts

#menu targets a single element with an ID called "element".eg.

<div id="menu">...</div>

.menu targets one or more elements with a class called "element".eg.

<div class="menu">...</div><div class="menu">...</div>

Use a class when you expect to use the same style for more than one element. Use an ID if you need to target exactly one particular element on the page.

Link to comment
Share on other sites

I use id for semantic reasons. And class for anything that might repeat.For example:

<div id="header"></div><div id="navigation">   <div class="menu"></div>   <div class="menu"></div>   <div class="menu"></div></div><div id="content">   <div class="box"></div>   <div class="box"></div>   <div class="box"></div></div><div id="footer"></div>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...