Forum Moderators: not2easy

Message Too Old, No Replies

#main-content OR div#main-content

         

gopal

4:49 am on Aug 22, 2007 (gmt 0)

10+ Year Member



When written as div#main-content it means that the ID must be contained by a div as in < div id="main-content>.

Can someone explain why they would use div#main-content instead of #main-content? It would help if you could give an example of a situation where div#main-content worked and #main-content did not.

Thanks

Marshall

6:46 am on Aug 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Either or, id's are only to be applied once on a page. By putting the element type in from: div#whatever, it is limted to a <div> tag whereas #whatever can be applied to whatever you want. Make sense?

Marshall

yannis

5:20 pm on Sep 4, 2007 (gmt 0)

10+ Year Member



#main-content is the preferred way. Since it is an id it can only be used once on the page (presumably on an div)

This would not work:

<p id="main-content"></p>

This would work though

<div id="main-content"></div>