Question about nested lists.

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

How am I supposed to go about doing this? If I code a nested list like so:

<ol>
   <li>Item 1</li>
   <li>Item 2</li>
      <ol type="a">
         <li>Item a</li>
         <li>Item b</li>
      </ol>
   <li>Item 3</li>
</ol>
'

I'll get an error message saying under xhtml 1.0 transitional as follows:

Quote: Line 19, column 9:

    ^
    Error: element "ol" not allowed here; assuming missing "li" start-tag

    Line 23, column 6:

  1. Item 3
  2. ^
    Error: element "li" not allowed here; possible cause is an inline element containing a block-level element

    Line 24, column 4:

^
Error: end tag for "li" omitted; end tags are required in XML for non-empty elements; empty elements require an end tag or the start tag must end with "/>"

Alright, so I take it I'm not supposed to nest lists like this. What is the right way to do it?

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

<ol>
   <li>Item 1</li>
   <li>Item 2 <-----------------------not here
      <ol type="a">
         <li>Item a</li>
         <li>Item b</li>
      </ol>
   </li>   <--------------------------here
   <li>Item 3</li>
</ol>
'

The nested list needs to go inside the list item.

Smiling S

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

You know what, I think I had that figured out a couple months ago but I completely forgot! Shows you how good my memory is.

THanks for reminding me Smiling

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

De nada. Only one of many minute adjustments in thinking needed to move over to XHTML/XML. It's an interesting journey, nothing has changed a lot, just everything seems to have changed a little bit.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

whoa, talk about serendipity -- I went away from here and immediately read a link to this: http://www.meyerweb.com/eric/css/list-indent.html how to style lists. heh. I thought it might be of interest.

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Thanks for that Suzanne Smiling

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Another question re: xhtml compatibility. How am I supposed to link to and external JavaScript?

If I do this: <script language="javascript" src="script.js"></script>, I get an error message upon validation saying that the required attribute "type" is not specified. If I put in the "type" attribute, the page breaks in NS 4.x. Is there a way to have this validate AND work in NS? Or will I have to accept that one error?

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

<script type="text/javascript" src="script.js"></script> should work in Netscape fine? It doesn't?

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Okay, sorry, I didn't know I was supposed to put text/ (dumb, I guess..)

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

You might find the professional version of html validator more helpful than the w3c validator, if you're not sure about some of the little details here and there. It has VERY helpful error messages -- it tells you what's wrong, and what the right things are.

I'm telling you, it's just the little details, lol. They get you (and me) every time! I was having a devil of a time with a style sheet not working, and I validated it and couldn't see the problem, but the styles were not working. Over and over, for hours it seemed. Then I realized I had put type="text/javascript" instead of type="text/css" in the .

*sigh*

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.