Jump to content
Sign in to follow this  
owosso

.menu vs. #menu

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.

Share this post


Link to post
Share on other sites

Hi,I personaly use more the class property. I think that's personnal and I prefer the class properties for styling and the ID for other function.Complements \o/

Share this post


Link to post
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>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...