HTML & CSS
I've been using XHTML for a while and I've always saved files with the extension ".html", like "index.html". However, I just noticed the my code editor (Aptana Studio) saves its templates as ".xhtml". I've never seen a ".xhtml" extension for a web page. Are you supposed to use the ".xhtml" extension for XHTML pages, or is ".html" fine?
An ".html" extension means the web server has been sending your page with the "text/html" mime type all this time, which also means that -- regardless of an XHTML doctype or self-closing slashes -- browsers have been parsing your code as if it were plain-old HTML. If you switch the extension to ".xhtml", then the web server might start sending your page with the "application/xhtml+xml" mime type, which is the mime type we're actually supposed to use for XHTML. The reason we don't is because IE <= 8 can't handle it. Also, if you make the switch to true XHTML, you may find that some markup, CSS, or JS is no longer compatible.
Oh, I didn't know that the file extension could override the doctype. Even so, it still validates as XHTML, which makes this even more confusing.
Yup. For example, check out these two pages:
They have exactly the same source code, yet they render differently. The only difference between them is that one is served as application/xhtml+xml and the other as text/html. That mime type is the only factor that determines whether the browser will parse your page as XHTML or HTML.
There is no reason to use XHTML. Especially now that html5 is becoming standard. FYI - notice there is no option for (x)html5. Why code in a dead language?
I'm using it until I fully understand how to use new html5 markup elements. Even if XHTML is dead, it still works.
XHTML5 is indeed being developed in parallel with HTML5.
As I understand it, whether you use .html or .xhtml makes little or no difference online, but there may be a difference when running the files locally.
As IE8 will be long dead by the time X()HTML 5 becomes a standard, when it does it will be the first version of XHTML that is actually usable.
XHTML is not dead, is normative (is backwards compatible) unlike HTML5. The future versions of XHTML will be reworked as XHTML5 most likely as HTML5 under MIME type: application/xhtml+xml.
There are three known file extensions that are currently in use for XHTML 1.x; ".xht", ".xhtml", and ".html". So by 2020, when HTML5.xx might be first usable hopefully IE8 will be long extinct.
The software is probably saving as: *.xht and *.xhtml because the files are based on pre-built templates and those extension are associated with XHTML documents not HTML 4.01 documents. I do save some files with the *.xht extension myself and have them online but like was mentioned; the MIME, the server sends matters more than if a hypertext-markup document has *.kangaroo , etc.
Oh, I didn't know that the file extension could override the doctype
On a *nix system, they can't, because they don't mean anything special. Like XHTMLcoder, you could have a foo.kangaroo file. Files are files, on *nix (though some applications may prefer to guess what a file type is based on extension). I could have HTML files on my server with no extension at all. So long as I set them to the correct MIME type and tell my server what to do with them, all's good.
But the headers the server sends out with the pages... that matters, exactly as Jeff Mott showed. How the server serves the page will override the meta tag (the meta tag is more of a fallback... for those nasty times when someone did not set up their server properly and it's sending out pages without headers stating what the MIME type is).
If your server does change which MIME type it associates your page with based on file extension, and you're not using a Windows server (I could be wrong, but I understand that on Windows, file extensions do mean something), then it's just a setting on your server to guess your intended MIME type. But that's a server setting, and not any kind of general rule about file extensions.
Nah, not really. I think when everyone realised what a pain XML was, the world moved on and XHTML will be used for those who actually have a use for XML and find using it also for their web stuff makes sense. Everyone else will have moved on to JSON I think
So it's not dead, but it's not something most of us have any real reason to use, other than personal preference.
I disagree - I think most people will stick with HTML rather than convert to JSON - particularly since JSON can't be used marking up web page content.
XML has millions more uses than either HTML or JSON and so will likely outlive both.
XHTML will be used by anyone who is using XML where one of the possibly dozens of uses they are making of their content is as web page content and also by anyone with a programming background - since it is far more logical in its operation than HTML is.
This topic is now closed. New replies are no longer allowed.