Hacker News new | comments | show | ask | jobs | submit login

Serious question: what is wrong with XHTML? I've been using the XHTML 1.1 Strict DTD for the last 3 years straight, always creating fully validating code. I found XHTML infinitely easier to appease than HTML4. Perhaps not as important, but I've also found that I can create nearly identical XHTML in different Web frameworks (depending on the task), which is important to some of my clients who don't have a lot of resources to upgrade the plethora of legacy systems they operate. I don't mean that as a brag "I'm so great", to the contrary, I've just found XHTML to be much more consistent and far easier to construct via robot than HTML4, meaning I don't have to be "so great" to use it.




Yes but - it's still true (for me at least), that XHTML is far easier to construct automatically. Mostly due to the tag-closing behaviour.

I don't spend all day writing HTML, so it's not at the forefront of my mind which tags are self-closing and which ones aren't. Is it "<br>" or "<br/>"? And really, why would I care? And ever more really, how much of that behaviour can I be bothered putting into automatically-produced output, rather than just simply putting the "/" everywhere?

If I cheat and serve up XHTML-like tags under a text/html mimetype, then nothing and nobody cares (as far as I can tell) except for the W3 validator.


You can't just put the / everywhere, and you still have to differentiate between non-empty and empty elements (e.g. div and br).

If you write XHTML, and don't follow these two non-XML rules (and indeed the other 14), then it'll probably break when you give it to an HTML parser or browser:

http://www.w3.org/TR/xhtml1/guidelines.html#C_2

C.2 Empty Elements: Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br></br> allowed by XML gives uncertain results in many existing user agents.

http://www.w3.org/TR/xhtml1/guidelines.html#C_3

C.3. Element Minimization and Empty Element Content: Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use <p> </p> and not <p />).


Mostly due to the tag-closing behaviour.

I guess I don't really understand this; best practice in HTML is to close tags and quote attributes just as in XHTML. The only difference is XHTML requires it.

As for self-closing tags, the only one I use, at all, is <img>, and I'm perfectly OK with having to handle that (largely because I don't; there are already libraries which will generate my HTML for me).


If you're using a serializer to write your document, it doesn't make any difference whether you serialize to XML or HTML. If you worry about where to put a '/', you should most likely be using a serializer instead of whatever you are doing.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: