Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested list Not valid? 1

Status
Not open for further replies.

UncleMortis

Programmer
Jan 28, 2003
120
AU
Just going through validating all of my pages and have discovered that my nested lists aren't valid.
Code:
document type does not allow element "UL" here; assuming missing "LI" start-tag.
  <ul class="subNav">
I don't understand why it won't allow it when it's just a nested list. Is there a way around this? If you click the "bikes" link, it will open the nested list. Website is Slowly being driven mad by validation. Though I must say not having validated a website for years, I've only had 1 error so far in the pages.
 
You're nesting the list incorrectly (closing the <li> too early).
A <ul> can't have another <ul> as a child: the new <ul> must be a child of the <li>. Remove the closing </li> and add it back in after the closing </ul>.
Code:
<ul id="mainNav">
<li><a href="index.html">Home</a></li>
<li><a href="aboutUs.html">About Us</a></li>
<li><a href="index.html">Bikes</a></li>
  <ul class="subNav">

  <li><a href="[URL unfurl="true"]http://www.trekbikes.com.au"[/URL] target="_blank">Trek</a></li>
  <li><a href="[URL unfurl="true"]http://www.giantbikes.net"[/URL] target="_blank">Giant</a></li>
  <li><a href="[URL unfurl="true"]http://www.feltracing.com"[/URL] target="_blank">Felt</a></li>
  <li><a href="[URL unfurl="true"]http://www.fisherbikes.com"[/URL] target="_blank">Gary Fisher</a></li>
  <li><a href="[URL unfurl="true"]http://www.gitane.com.au"[/URL] target="_blank">Gitane</a></li>
  <li><a href="[URL unfurl="true"]http://www.apollobikes.com"[/URL] target="_blank">Apollo</a></li>

  <li><a href="[URL unfurl="true"]http://www.racelinebikes.com"[/URL] target="_blank">Raceline</a></li>
  </ul>
<li><a href="scooterSays.html">Scooter Says</a></li>
becomes
Code:
<ul id="mainNav">
<li><a href="index.html">Home</a></li>
<li><a href="aboutUs.html">About Us</a></li>
<li><a href="index.html">Bikes</a>[red][s]</li>[/s][/red]
  <ul class="subNav">

  <li><a href="[URL unfurl="true"]http://www.trekbikes.com.au"[/URL] target="_blank">Trek</a></li>
  <li><a href="[URL unfurl="true"]http://www.giantbikes.net"[/URL] target="_blank">Giant</a></li>
  <li><a href="[URL unfurl="true"]http://www.feltracing.com"[/URL] target="_blank">Felt</a></li>
  <li><a href="[URL unfurl="true"]http://www.fisherbikes.com"[/URL] target="_blank">Gary Fisher</a></li>
  <li><a href="[URL unfurl="true"]http://www.gitane.com.au"[/URL] target="_blank">Gitane</a></li>
  <li><a href="[URL unfurl="true"]http://www.apollobikes.com"[/URL] target="_blank">Apollo</a></li>

  <li><a href="[URL unfurl="true"]http://www.racelinebikes.com"[/URL] target="_blank">Raceline</a></li>
  </ul>
  [red]</li>[/red]
<li><a href="scooterSays.html">Scooter Says</a></li>

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
Thanks heaps Mate, The thought did cross my mind, but it wasn't making sense, the top way is how I've done it since the dawn of time. Same example is in one of my books too. Thanks again for that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top