Conrad11 said:
People keep telling me to make my code XHTML 1.0 Strict.
What are the advantages of this?
The advantages depend on what it's being compared to. Instead of HTML 4.01? Instead of a Transitional DTD? Or something else? XHTML is a parallel standard to HTML, and neither one can currently be called 'better' than the other in a blanket statement; it depends on application and context.
Mr_L said:
Really sorry to play Devil's advocate, but some of these points just aren't true. For "table-layouts vs CSS-layouts" or "validating vs non-validating" they're totally valid and great points, but not in a comparison of XHTML 1.0 with HTML 4.01
. I understand where you were coming from, but the muddle of XHTML with CSS layouts and semantics is a little bugbear of mine and I haven't had anywhere else more appropriate to post about it.
It's pretentious of me to say, but there have been lots of replies over the months to threads containing table-based layouts where the replies are to "use XHTML and CSS" or just "use XHTML, it's better", without an apparent understanding of why that statement's being made. XHTML has got involved more by coincidence than by its real value as a markup language in that respect. Switching to CSS layouts does not mean you
have to use XHTML; using HTML is just as good and shouldn't be frowned upon in the way that it appears to be. It's no less clean, no less semantic, no slower or less efficient and for most people is exactly what their XHTML is being interpreted as - XHTML sent as text/html is parsed by the user-agent's HTML (SGML) parser, not the XML parser. Doesn't mean it's not XHTML, just not parsed as such and so any comparisons of efficiency/speed are negated.
- Stricter/cleaner and more efficient.
XHTML is only more strict by requirement of its design as an application of XML. HTML can be written just as strict and clean. There is a strict 4.01 DTD, but hardly anyone seems to follow it, preferring the looseness and presentational idioms of the Transitional DTD - which has given HTML its unfairly poor reputation as a markup language for the modern standards-promoting developer.
I would agree that the nature of XHTML's strictness is a great advantage, in that it promotes (by requirement) good coding habits like consistency and well-formedness.
- Easier and quicker to write than HTML 4.0.
Debatable. Theoretically HTML should be quicker to write because of optional tags and attribute minimisation. Easier? I disagree. There's no difference, they both have the same set of elements. They only really differ syntactically, and the differences shouldn't really present any issue for anyone with the ability to use a computer.
- Used in conjunction with CSS makes loading times faster.
Benchmarks?
. The syntax requirements of XHTML mean that pages can potentially be larger in filesize than the equivalent HTML 4.01 page with judicious use of optional tags.
- More cross browser compatible than previous versions.
I think that depends what angle you're coming from. There's not even support for [proper] XHTML in IE, whereas it handles HTML fine. User-agents have to do more error-correction to a 'valid' XHTML page sent as text/html against a valid HTML 4.01 (Strict) page - where there will typically be no need for error correction. The reason? You don't close "EMPTY" elements in HTML 4.01, so it has to discard all those lovely />s.
On the flip-side, XHTML 1.0 can be read by both XML user-agents and HTML/SGML user-agents, and is easier to parse, promoting wider compatibility.
- Better Search Engine Optimisation.
I haven't yet seen any evidence to back this up.
Easier to write a search-engine
for (not that I can talk on that at all authoritatively), but as of now there are little benefits for SEO. Search engines have been handling HTML for a decade, and they're more than comfortable with it.
- More effective and stylistic than tables.
Again, no difference. You can write as much crufty, table-based, bodged but valid markup in XHTML as you can in HTML.
As I say, it all depends on what you're comparing to what. Which is better: HTML 4.01 Strict or XHTML 1.0 Transitional?