Sublime directory Surf the web anonymous Pagerank Monitor


To <ul ="navlist"> or not to <ul ="navlist">

Happy Guy
Sun 27 July 2008, 06:31 pm GMT +0200
As I've looked at various CSS files for the layouts of websites, I've noticed that some have a list set up as:

<div id="navcont")
<ul id="navlist">
<li><a href="*">Link</a></li>
<li><a href="*">Link</a></li>
<li><a href="*">Link</a></li>
<li><a href="*">Link</a></li>
<li><a href="*">Link</a></li>
</ul>
</div>

Yet others have the list without the id "navlist" in the <ul>.

<div id="navcont")
<ul>
<li><a href="*">Link</a></li>
<li><a href="*">Link</a></li>
<li><a href="*">Link</a></li>
<li><a href="*">Link</a></li>
<li><a href="*">Link</a></li>
</ul>
</div>


To me, it seems like extraneous code to have a separate id in with the <ul>. Is there an advantage to putting a separate id in with the <ul>? Or is it just adding more code than necessary?



olaf
Sun 27 July 2008, 08:59 pm GMT +0200
you can use an ID only once, if you have multiple list inside the container "navcont" it's better to use a "natural" list element.

you can style the list also like this:

#navcont ul { ...}

anthonyw
Mon 28 July 2008, 11:28 am GMT +0200
If you have a single navigation list, either style works. However I would prefer to put an ID on the UL itself, since this allows you to put other ULs in the same DIV that aren't part of the navigation list without them being accidentally styled as a nav list.

Alternatively, you can style the list by using a class rather than an ID. This allows you to have multiple nav lists on the same page, or use the stylesheet on multiple pages without requiring the same ID for the nav list on every page.

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional