Log in

View Full Version : How to do a list in a list with XHTML and validate



Markxxx
03-17-2007, 12:37 AM
I have been trying to do a list in a list with XHTML and validate it. I used this script and it does work fine, but it won't validate. It says a violation between an inline and a block line element.

I thought about using a definiton list which may work too but wouldn't get me the numbers in front of the lists.

Here's the script any ideas how I can change it so it validates with XHTML or ideas which I haven't thought of?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Here</title>
<style type="text/css">
ol{line-height: 150%;
list-style-type: upper-alpha;
}
ol ol{list-style-type: decimal}
</style>
</head>
<body>
<ol>
<li>Number 1</li>
<ol><li>Info Here</li>
<li>Info Here</li>
<li>Info Here</li></ol>
<li>Number 2</li>
<ol><li>Info Here</li></ol>
<li>Number 3</li>
<ol><li>Info Here</li></ol>
</ol>
</body>
</html>

boxxertrumps
03-17-2007, 12:49 AM
<ol>
<li>Number 1
<ol><li>Info Here</li>
<li>Info Here</li>
<li>Info Here</li></ol>
</li>
<li>Number 2
<ol><li>Info Here</li></ol>
</li>
<li>Number 3
<ol><li>Info Here</li></ol>
</li>

you have to have the inner list inside an outer list's item.

thetestingsite
03-17-2007, 12:49 AM
Try this:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Here</title>
<style type="text/css">
ol{line-height: 150&#37;;
list-style-type: upper-alpha;
}
ol ol{list-style-type: decimal}
</style>
</head>
<body>
<ol>
<li>Number 1</li>
<li>
<ol>
<li>Info Here</li>
<li>Info Here</li>
<li>Info Here</li>
</ol>
</li>

<li>Number 2</li>
<li>
<ol>
<li>Info Here</li>
</ol>
</li>

<li>Number 3</li>
<li>
<ol>
<li>Info Here</li>
</ol>
</li>
</ol>
</body>
</html>


This code validates for me. Hope this helps.


EDIT: Sorry boxxertrumps, posted same time.

Markxxx
03-17-2007, 01:03 AM
Thanks so much. Do you know how many time I looked at this. I even went to the library and got a book, and I just kept copying down the example wrong.

I should've been able to catch this, but anyway thank you both. You guys are great

:)

Twey
03-17-2007, 08:35 AM
You are aware that IE doesn't support XHTML?

Sparaker
03-21-2007, 04:32 PM
You are aware that IE doesn't support XHTML?

And exactly how do you say that ? XHTML is not like a completely different markup language its just a new standard which is more efficient. it works just about fine with IE. :p

Twey
03-21-2007, 04:41 PM
XHTML is not like a completely different markup language its just a new standard which is more efficient. it works just about fine with IE.Wrong. Dead wrong.

Firstly, XHTML is an entirely new markup language. It's not even based on the same standard: XHTML is a profile of XML, while HTML is a profile of SGML. It just happens to have some of the same elements.
Secondly, XHTML does not work in IE at all. If you send a correct XHTML page, using the MIME type for XHTML (application/xhtml+xml), IE will ask the user where to save the file. If you try to pretend it is HTML by sending it with a text/html MIME type, IE (and all other browsers) will generally error-correct it into HTML, since the syntaxes of the two languages are similar enough that this is possible, but don't be fooled: this is less efficient than correct HTML to parse, not more, and none of the new features of XHTML will be available. You are effectively serving poorly-formed HTML.

Sparaker
03-21-2007, 04:55 PM
Wrong. Dead wrong.

Firstly, XHTML is an entirely new markup language. It's not even based on the same standard: XHTML is a profile of XML, while HTML is a profile of SGML. It just happens to have some of the same elements.
Secondly, XHTML does not work in IE at all. If you send a correct XHTML page, using the MIME type for XHTML (application/xhtml+xml), IE will ask the user where to save the file. If you try to pretend it is HTML by sending it with a text/html MIME type, IE (and all other browsers) will generally error-correct it into HTML, since the syntaxes of the two languages are similar enough that this is possible, but don't be fooled: this is less efficient than correct HTML to parse, not more, and none of the new features of XHTML will be available. You are effectively serving poorly-formed HTML.

I didn't meant it in the way of using its own mime type header along with the HTTP protocol. all i meant was that IE renders it no different from firefox if the page is XHTML validated. and you keep the mime type header same. :rolleyes:

Twey
03-21-2007, 05:01 PM
all i meant was that IE renders it no different from firefox if the page is XHTML validated. and you keep the mime type header same.Both treat it as invalid HTML, but since Quirks mode is unpredictable, variations will eventually appear.
all i meant was that IE renders it no different from firefox if the page is XHTML validated. and you keep the mime type header same.That's not XHTML.

Sparaker
03-21-2007, 05:09 PM
Both treat it as invalid HTML, but since Quirks mode is unpredictable, variations will eventually appear.

Okay okay you win. ;)

boxxertrumps
03-21-2007, 08:04 PM
But the growing trend of web designers using xhtml will most likely force MS into writing a correct rendering engine for it.

So all it is, is waiting to see what comes first, the variations or the update.

Twey
03-21-2007, 09:01 PM
We can hope so.

Of course, HTML 5 is on its way too, and looks exciting. We might see support for that first.