Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Using CSS With No HTML At All (css-tricks.com)
29 points by mambodog on Dec 15, 2010 | hide | past | favorite | 9 comments


"But it's almost 2011, who’s still using XHTML anyway?"

This caught me totally off guard. My experience has been that XHTML is much easier to manage across browsers than HTML 4. Can anyone chime in as to whether I'm crazy?


Yes, you are. There is zero benefit in using XHTML with text/html. You can have lowercase tags and quoted attributes in HTML4 if you want so. You don't pollute your markup with meaningless "/" which browsers treated as the invalid attribute anyway. Ok, it's not actually meaningless but <br /> in HTML(SGML) means completely different thing than in XML, only browsers did not implement that part properly. Is short: if you were using XHTML markup with text/html MIME, you were using marketing XHTML, which was parsed by browsers' engines as HTML not XML anyway. If you were using application/xhtml+xml MIME type you'd know the difference. It would be interesting to see how XHTML was "easier to manage across browsers" given that IE does not even understand XHTML.

I used XHTML for a short while before I learned what it actually meant. Then I switched to HTML4.01, now HTML5. The nice thing about HTML5 is that it let's you have any syntax you want and it is not based neither on SGML nor XML.


Could you explain the <br> vs <br /> difference in HTML? HTML5 spec says that void elements may optionally include slash[1], and from the wording I'd assume that it means that they should be treated equally.

[1] http://dev.w3.org/html5/markup/syntax.html#void-element


As I understand it, basically the 'self-closing tags' are considered valid markup, but this comes under WHATWG's philosophy of trying to be inclusive as much existing markup that is out there as possible (within reason). This is in opposition to the strictness of XHTML's approach.

This post by hixie indicates that self-closing tags are allowed to 'ease migration': http://lists.whatwg.org/pipermail/help-whatwg.org/2008-Augus...

I believe the 'spirit' of the spec would imply that <br> is the best practice when writing new markup. HTML5 maintains no pretence of being XML.


This is actually very tricky subject. In short: HTML is SGML application, and in SGML features section (http://www.w3.org/TR/html401/sgml/sgmldecl.html) it has this little tidbit: SHORTTAG YES. This allows the usage of so called null-end tags: ability to close the tag with a single character, which happens to be solidus ("/"). So in essence <br/> in HTML should mean the same as <br>>, i.e. "/" closes the tag and then ">" is just some text.

If you try to validate document using xhtml markup as html you may get this warning from validator:

  NET-enabling start-tag requires SHORTTAG YES
  The sequence <FOO /> can be interpreted in at least two different
  ways, depending on the DOCTYPE of the document. For HTML 4.01
  Strict, the '/' terminates the tag <FOO (with an implied '>').
  However, since many browsers don't interpret it this way, even
  in the presence of an HTML 4.01 Strict DOCTYPE, it is best to
  avoid it completely in pure HTML documents and reserve its use
  solely for those written in XHTML.
In XML (and hence XHTML) with the help of some mind-boggling trickery (Web SGML Adaptations Annex) you can have things like <foo/>


Thanks for the info. Perhaps I just got better about writing clean markup around the same time I started using XHTML, and confused the two. I suppose now's as good a time as any for me to embrace HTML5.


The frustrating thing is that if not for IE, we could all have served real XHTML as application/xhtml+xml by now. Instead, we have to wait a year for IE9 to release, and then how many years for IE8 to finally become obsolete. And that when right now it is already almost 11 years after the release of XHTML 1.0.


Given that this site is mainly concerned with CSS3 and other new hotness, I'd say their implication is that people these days use HTML5. While I'm not sure I'd suggest using the new HTML5 tags in all projects yet, I think it's fair to say that there's no future in XHTML, and that you might as well use <!DOCTYPE html> and just stick to HTML4.01 compatible tags.

I don't see why XHTML would be any easier to manage than well-formed HTML, provided you trigger standards mode and the right IE-compatibility modes.


I still prefer using well-formed XML when serving HTML, even if it is HTML5 being served as text/html. I like being able to use XML tools when dealing with html, e.g. XPath queries in automated tests, etc..

This obviously does take some effort to get right, and for most people may not be worth the trouble. W3C has some info on this practice here:

http://dev.w3.org/html5/html-xhtml-author-guide/html-xhtml-a...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: