SWEngineer Posted July 12, 2010 Share Posted July 12, 2010 In this HTML/CSS http://css.maxdesign.com.au/listamatic/horizontal02.htmUnder HTML:<div id="navcontainer">But, navcontainer is not included in the CSS section, what is this id supposed to do?Under CSS:What does the following mean?ul#navlist#navlist liAnd, what is the difference between those two different forms? I mean here, the way the preceding is written. In the first script I see for example ul BEFORE #, and in the second one, I see that li is AFTER #.Can you explain that?Thanks. Link to comment Share on other sites More sharing options...
chibineku Posted July 12, 2010 Share Posted July 12, 2010 IDs are not only used by CSS, so perhaps navcontainer is an id used by JavaScript to find the div. It's good practice to give major structures in your code an id because you will almost always wish to style them and it's the easiest way of selecting them.ul#navlist - means the unordered list with the id 'navlist'#navlist li - means all list items in the element with id 'navlist' (which we know to be an unordered list)The hash/pound sign (#) is used to select elements with a certain id, and the . syntax (for example, div.red) is used to select elements with a certain class. Classes can be used more than once on a page, but ids are unique. Note in the above examples that if ul#navlist had been written with a space - ul #navlist - the style would be applied to the element with id 'navlist' that is a child of any unordered list. I hope that helps. Link to comment Share on other sites More sharing options...
Howdy_McGee Posted July 12, 2010 Share Posted July 12, 2010 Probably for future use, incase he needs to quick edit everything in the Navigation. Or like the poster above said, if he used any javascript he could use the ID to locate the entire Navigation. Link to comment Share on other sites More sharing options...
jeffman Posted July 13, 2010 Share Posted July 13, 2010 It is generally a good idea to give major and semi-major structures an ID so that you know what your looking at when you see it. Debugging a page in something like DOM Inspector is also a lot easier if a structure has an identifier.All this is quite separate from CSS and JavaScript utility. Link to comment Share on other sites More sharing options...
SWEngineer Posted July 16, 2010 Author Share Posted July 16, 2010 Thanks all for your replies. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.