CodyBugstein
CodyBugstein

Reputation: 23372

What is "Extensible" about XHTML?

Why is XHTML called "eXtensible" (the X in XHTML)? Can we, as individual web developers actually extend it?

What separates it from ordinary HTML?

Upvotes: 0

Views: 143

Answers (1)

Rich Bradshaw
Rich Bradshaw

Reputation: 73055

Well, firstly, things have moved on somewhat, and XHTML isn't really a thing anymore. HTML5 isn't parsed as XML, and XHTML 2.0 was of course cancelled.

Despite that, it's possible to use XHTML if you use the application/xhtml+xml mimetype, just be aware of the various shortcomings of that (any error = yellow screen of death, older IEs don't render anything at all).

For a new project, use the HTML5 doctype and serve as text/html. XHTML can be considered as a failure for many reasons.

Anyway, with XHTML you can do things like this:

<!DOCTYPE html SYSTEM "http://example.com/my-xhtml-custom.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:custom="http://example.com/" xml:lang='en-US'>

then copy http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd and edit it how you like, and put it where we referenced earlier.

The w3c have a lot to say about this, specifically:

Don't do this! Documents need to have a meaning as well as correct syntax. SGML and XML only define syntax. HTML and XHTML define meaning. If you add elements that aren't defined by a standard, only you yourself know what they mean. And in 20 or 50 years, even you may not know it anymore…

Of course, you can experiment, for example to work on future Web formats, but other than that you should not use proprietary elements.

Nowadays, we thankfully have HTML5 which dropped all this XML stuff (no one was using it and it adds a lot of complexity). It's not extensible in the same way, but that's probably a good thing!

Upvotes: 1

Related Questions