January 27, 2008

XHTML Valid Nested-List

Filed under: XHTML — Soleer @ 9:39 pm

So, I began testing all of my sites for XHTML compliance. I noticed that some of my nested lists were not validating. They all displayed properly, but (*gasp*) they weren’t valid XHTML. Here’s what I found the problem was, and the resulting solution:

I was displaying the following list:

  • Item 1
  • Item 2
  • Item 3
  • Item 4
    • Sub-Item 1
    • Sub-Item 2
  • Item 5
  • Item 6

After a little research, I discovered that my markup was as following:

<ul>
     <li>Item 1</li>
     <li>Item 2</li>
     <li>Item 3</li>
     <li>Item 4</li>
     <ul>
          <li>Sub-Item 1</li>
          <li>Sub-Item 2</li>
     </ul>

     <li>Item 5</li>
     <li>Item 6</li>
</ul>

When in fact, it should actually be:

<ul>
     <li>Item 1</li>
     <li>Item 2</li>
     <li>Item 3</li>
     <li>Item 4
          <ul>
               <li>Sub-Item 1</li>
               <li>Sub-Item 2</li>
          </ul>
     </li>
     <li>Item 5</li>
     <li>Item 6</li>
</ul>

Note how the <ul> tags are enclosed in the parent <li> item in the Valid XHTML example. Pretty simple stuff, but I’m sure there are others out there making the same mistake. Let’s all get our stuff together, and become compliant.

1 Comment »

  1. I did a lot of searching before finding this page. It really helped! Thanks a bunch.

    Rick

    Comment by Rick — March 21, 2008 @ 7:30 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Who we are

Explore our history and character.

If you've ever been on a blind-date, odds are great that you know how disastrous "jumping before looking" can be. Feel free to do some online stalking here before you contact Soleer.

What We Do

"Girls only want boyfriends who have great skills." -Napoleon Dynamite

While we aren't looking to be your boyfriend and might not have "nunchuku skills," we do offer a number of other services and solutions to assist your organization.

What We’ve Done

As we say in Texas, "This ain't our first rodeo." Take a look at a sampling of some of our masterpieces, from logo design and brochure creation to webpage design and online community development.