Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- XHTML validating
November 14, 2007, 10:27 am
rate this thread
for a college assignment and the W3C validator refuses to validate it
- "text/plain is not supported".
The file has the extension .htm (i've tried changing this to .html),
and when the code is copied into the direct input part of the
validator it is validated as valid. In addition, the Page Valet and
WDG validators both tell me my page is valid when it is uploaded.
Can anybody please let me know what I could be doing wrong.
This is the first time i've used this, if there is any more
information that you require please just let me know.
Re: XHTML validating
First some background information: You just shouldn't use XHTML. Use
HTML 4.01 Strict instead and also check that you've used a doctype
appropriate to trigger standards-mode rendering in your browser.
This is regularly and widely discussed here in the past. Search for
If a course teaches you to use XHTML instead of HTML, they're probably
wrong. If a course that teaches XHTML doesn't also teach the drawbacks
to it, then it's definitely wrong. O'Reilly's "Head First HTML with
CSS & XHTML" has a good approach to this. I'm also wary of any course
that can talk about "validating" XHTML without first explaining the
drawbacks of XHTML.
The problem is that it's impossible to "do XHTML right", as IE simply
rejects it. We must either use a work-around (Appendix C) or we should
simply stick with HTML. For _published_ work on the web, it's simpler
and better to stick with HTML in all cases (there's some
justification to its use for internal XML-based processing inside a
You can validate XHTML as _either_ text/html or as an XML or
specifically XHTML content-type. You must serve it as text/html onto
the web, if you're hoping to get IE to work with it. The validator's
behaviour will also vary slightly according to which content-type you
If you serve XHTML as text/html you're actually "cheating". This is
the basis of Appendix C. The browser no longer receives XHTML, it now
gets HTML (because that's what it was labelled as) and treats it as
such. The document is slightly broken by having been authored as
XHTML, but it turns out they're close enough to work satisfactorily.
Issues like element closure though will be processed according to HTML
rules, not XML rules.
The server is mis-configured. It should serve it as "text/html"
This is usually sufficient to cause a well-configured web server to
serve it with an appropriate content type. If it doesn't, then simply
reconfigure httpd.conf or .htaccess (if it's a shared server and you
don't have control of httpd.conf). The rest is an exercise in web
searching for Apache configuration. If you're not using Apache, then
start doing so. Adding the following lines to .htaccess (create it if
needed) should sort you out:
AddType text/html .htm
AddType text/html .html