You are here: Re: most XHTML on the web is invalid? « HTML « IT news, forums, messages
Re: most XHTML on the web is invalid?

Posted by cwdjrxyz on 02/05/06 19:20

John Salerno wrote:
> What exactly does this mean:
>
> "Document sent as text/html are handled as tag soup [1] by most UAs.
> This means that authors are not checking for validity, and thus
> most XHTML documents on the web now are invalid. Therefore the main
> advantage of using XHTML, that it has to be valid, is lost of the
> document is then sent as text/html."
>
> To me it sounds like he is saying that *any* document written in XHTML
> and then served as text/html is invalid. But is that really the case? Or
> is he saying that the document *could* be invalid because it could still
> be prone to the methods of HTML (e.g., no closing tags, etc.)?
>
> I assume if you validate your XHTML, then simply serving it as text/html
> doesn't harm it, right? It doesn't suddenly make it "invalid," does it?
> (Perhaps in a strict sense it does, because it's not truly XHTML, but as
> far as the actually words in the document themselves, they are still
> valid, right? And if it was then served as application/xhtml-xml, it
> would be valid, correct?)

You have had many answers with useful information. I just want to add a
practical consideration or two.

No matter if you write your page in perfect html or perfect xhtml, if
you label the page as something.html, it gets served as html by most
servers. If you want to serve a xhtml page as true xhtml you need to
set the mime type of application/xhtml+xml, associated with some
extension such as .xhtml, on the server and serve the page with the
extension such as .xhtml selected. A good xhtml page then gets served
correctly. And it will not be viewed by browsers such as IE6 that do
not understand the mentioned mime type. If you want IE6 and such to
view the page, you either have to serve a separate html page for it, or
use a trick such as writing a php include at the top of the
something.php page that will serve the page as xhtml only if the
server/browser header exchange indicates that the browser will at least
accept application/xhtml+xml. If not, then the page gets served as
html. A few browsers will not tell if they will accept this mime type
or not even when they will accept true xhtml. In that case you would
serve the page as html anyway to be on the safe side, or you are back
to writing separate pages for html and xhtml. Then you need to check
the page on a few browsers to make certain the automatic conversion to
a html page for IE6 and such is working.

When you use a xhtml aware browser(Opera, Firefox, etc) and serve the
page as application/xhtml+xml, the browser then parses the page as xml.
Little errors that might not cause much of a problem on an html page
then sometimes result in the page not showing, and you also often get
an xml parse error.

Concerning the W3C validator, if you serve a page (written in html or
xhtml code) as something.html, the validator views the page as html.
If you serve as application/xhtml+xml, the validator views the page as
xhtml. If you use the extended interface at the validator, it will tell
you the mime type of the page it views. However the validator validates
the code of the page as indicated in the Doctype. Thus if you serve an
xhtml page as html, the validator will still validate the code as
xhtml, gripes about unclosed img and br tags, etc. However it does not
determine if the page is being served correctly(other than with the
mime type displayed using the extended interface). I suspect this is
one reason some think they are serving xhtml, when they actually are
not.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация