a class within an id?

admin

Administrator
Staff member
I have the following xhtml:

<div id="mainnav">
<ul>
<li class="1"><a href=http://www.webdeveloper.com/forum/archive/index.php/"#">Home</a></li>
<li class="2"><a href=http://www.webdeveloper.com/forum/archive/index.php/"#">News</a></li>
<li class="3"><a href=http://www.webdeveloper.com/forum/archive/index.php/"#">Industry News</a></li>
<li class="3"><a href=http://www.webdeveloper.com/forum/archive/index.php/"#">Internal News</a></li>
<li class="2"><a href=http://www.webdeveloper.com/forum/archive/index.php/"#">Unit Sectors</a></li>
<li class="3"><a href=http://www.webdeveloper.com/forum/archive/index.php/"#">Books & Magazines</a></li>
<li class="3"><a href=http://www.webdeveloper.com/forum/archive/index.php/"#">Education content</a></li>
<li class="3"><a href=http://www.webdeveloper.com/forum/archive/index.php/"#">Newspapers, Databases & Directories</a></li>
</ul>

</div>

and use the following CSS:

#mainnav ul li.1{
border-top: 2px solid black;
padding-top: 5px;
padding-bottom: 5px;
background-color: #86BAEC;
font-weight: bold;
}

#mainnav ul li.2{
border-top: 1px solid black;
padding-left: 20px;
background-color: #5383B3;
}

#mainnav ul li.3{
border-top: 1px solid black;
padding-left: 25px;
background-color: #003366;
}

#mainnav ul li.4{
border-top: 1px solid black;
background-color: #FFFFFF;
}
etc
but the CSS is invalid apparently. How do I refer to a <li> with class 1 - 4, within an id section?

The page displays right, but I want it to validate correctly too! Thanks in advance.Start the class with a character, not a number.ah grand - thanks!It took a bit of searching, but here are the rules: <!-- m --><a class="postlink" href="http://www.w3.org/TR/CSS21/syndata.html#q6">http://www.w3.org/TR/CSS21/syndata.html#q6</a><!-- m -->
 
Back
Top