PDA

View Full Version : Should meta tags be closed in transitional XHTML?


ze0nyx
02-16-2005, 09:18 AM
I've read somewhere that in XHTML all tags must be closed. I have the following meta tag:<meta name="Description" content="Developer's Heaven" />And it fails in the W3C validator. The error I get isYou have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>) or forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes).When I remove the backslash and space at the end of the tag the code doesn't fail in the validator. So I come to the conclusion that meta tags are an exception and should not be closed. Am I wrong?
Also, if you look at the validator result I've quoted, you'll see something strange. It says that the content should not be put directly inside the body tag but in some other tag. Is that right? What if I do it this way:<body>Hello world!</body>

rmedek
02-16-2005, 09:26 AM
Meta tags should be closed, like you have written above. There might be another error in your code that is cascading to that line.

The part about the <body> text is right on the validator's end, though. All text should be enclosed in something that defines what the text is. So, "<body>text</body>" would show an error but "<body><p>text</p></body>" wouldn't.

ze0nyx
02-16-2005, 10:12 AM
Meta tags should be closed, like you have written above. There might be another error in your code that is cascading to that line.

The part about the <body> text is right on the validator's end, though. All text should be enclosed in something that defines what the text is. So, "<body>text</body>" would show an error but "<body><p>text</p></body>" wouldn't.Thank you. I've found my error. I've used a HTML 4.01 DTD instead of a XHTML one. But I tried to put some text directly into the <body> and the document validated!

rmedek
02-16-2005, 10:18 AM
The advice I gave above was meant for XHTML Strict... If you're using HTML 4.0 or Transitional it'll probably let you validate it.