View Full Version : Confused by XHTML (In)Validation
nolachrymose
11-29-2003, 03:35 PM
I have just gotten into using XHTML 1.0, and am confused by the validation. I have read the w3.org Specifications and such, and I think I've followed everything correctly, but I get some odd errors that repeat themselves and don't make sense to me. Every error on my page looks something like this, although sometimes with different elements:
Line 10, column 21: document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag
<div class="header">navigation</div>
I have no idea why "document type does not allow element." Does anyone have any insight in this?
The URL for the validation on the page is <http://validator.w3.org/check?uri=http%3A%2F%2Fwww.anime-republic.com%2Frohit%2Frival%2Fboxes.htm&charset=%28detect+automatically%29&doctype=%28detect+automatically%29>, and the DTD is XHTML 1.0 Transitional.
Thanks for the help!
Happy coding! :)
liorean
11-29-2003, 03:50 PM
To understand this, you must look at the previous line. Almost all validation errors are captured first when you have already made a mistake, not then you are about to make a mistake.
9: <span id="content1">
10: <div class="header">navigation</div>A span element may only contain inline or modification elements. Some of these elements, however, may contain a div. Notably, the ones that may do so are "object", "applet", "map", "iframe", "button", "ins", "del"So, the validator replies with telling you what to do to make the situation validate under present conditions, instead of telling you why present conditions doesn't allow the situation to validate. So, when you encounter errors like this, take note of the container and the rules governing that container, and not only what the validator tells you about the element that introduced the invalid situation.
nolachrymose
11-29-2003, 03:55 PM
Ah, that makes sense. But what about paragraph elements...aren't they block elements, and as such can contain things like div elements?
liorean
11-29-2003, 04:19 PM
They are block elements themselves, yes, but their content must be inline.
Not all block level elements can contain inline elements, and vica versa. For examle, body (block) can contain only block elements, whereas p (block) can contain only inline elements.
Some elements can only contain certain elements, for example ul (block) can only contain li (block), and table (block) can only contain th, td or tr elements (all block).
nolachrymose
11-29-2003, 04:56 PM
Alright, thank you both for the help! The page *validates*, yay. :cool:
liorean
11-29-2003, 05:37 PM
Originally posted by me'
and table (block) can only contain th, td or tr elements (all block). Actually, the table element may contain very much more than that. Tables are structurally quite complicated and you can't easily represent them in a sequential manner, so there are lots of different things to represent their inherent structure. In [HTML4], tables may in fact only contain zero or one caption, thead and tfoot; zero or more of either col or colgroup (which means they are mutually exclusive); and one or more tbody. Tbodies require one or more tr but have optional opening tags, so in that way you may also use tr directly within the table, because the tobody is implicitly there even it you haven't written it in the source code.
In [XHTML1] however, the W3C had to accept that they made a mistake in HTML that they couldn't afford to correct in XHTML, and thus in XHTML, where elements may not be implicit, instead of requiring one or more tbodies they require either one or more tbodies or one or more tr. Tbody and tr are thus mutually exclusive (which they were not in HTML), and the XML document tree of an XHTML document does not contain a tbody in the cases of tr appearing as a direct child of the table.
And, actually, the table elements have an entirely own display model, which is somewhat alike the block model but not exactly.
Okay, okay, bad example.
You know far too much :p Thanks for the info, though.
liorean
11-29-2003, 05:50 PM
Originally posted by me'
You know far too much :pNope - I cheat. I have a copy of the html4.01, the xhtml1 transitional and the xhtml1 strict dtds on my desktop, and I use them to look markup things up every time I need to. For CSS I have a set of links to the specs that I use quite frequently.
As for JavaScript, though, that's all in my head, though. It's a rare case when I have to look up something for my own use.
Alex Vincent
11-30-2003, 06:02 AM
Originally posted by liorean
Nope - I cheat. I have a copy of the html4.01, the xhtml1 transitional and the xhtml1 strict dtds on my desktop, and I use them to look markup things up every time I need to. For CSS I have a set of links to the specs that I use quite frequently.
You call that cheating? Pff. I keep a whole directory on my C: drive specifically chock-full of W3C specifications. :cool:
liorean
11-30-2003, 02:32 PM
Originally posted by Alex Vincent
You call that cheating? Pff. I keep a whole directory on my C: drive specifically chock-full of W3C specifications. :cool: Well, I did that too, some time ago. Nowadays I simply keep linklists to W3C's online specs instead of keeping copies. I'm not on a modem any longer... Keeping the DTDs at hand is another thing, however, because I've got a few useful tools for fast handling of them. For example, I can tell it to display all the possible contents elements of the div element, and it will display all the entities and notations that are relevant.
Originally posted by liorean
Well, I did that too, some time ago. Nowadays I simply keep linklists to W3C's online specs instead of keeping copies. I'm not on a modem any longer... Keeping the DTDs at hand is another thing, however, because I've got a few useful tools for fast handling of them. For example, I can tell it to display all the possible contents elements of the div element, and it will display all the entities and notations that are relevant. Useful! Where did you get it? Is it free?
liorean
11-30-2003, 05:17 PM
I've got a lot of DTD handling tools, some of them scripts I've written myself. You can find most of it at <http://horizon.nserl.purdue.edu/Xml/XMLtools.html>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.