Forum Moderators: open

Message Too Old, No Replies

HTML v.s. XHTML

which is the best?

         

fashezee

11:46 am on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you choose between HTML or XHTML for a project, and why?

brotherhood of LAN

5:09 pm on Jun 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>>The WYSIWYG editor crowd

Don't suppose you're in that CSS bunch are ya ;) I write HTML/XHTML in DW or Notepad, makes no difference to me, or anyone else.

I switched to XHTML because of whats been mentioned about XHTML and the "semantic web". If I can make my info more "uniform", then I will. (and take what papapaer says as the right answer in most instances :))

It only took 5 minutes and some regex (in DW actually) to do the switch. Hopefully when I'm more familiar with XML my code won't need to be re-hashed into a more "machine readable" form.

torrent

8:30 am on Jun 13, 2003 (gmt 0)

10+ Year Member



This is a problem, as valid XHTML is actually invalid HTML.

I find this an interesting statement. How do any XHTML 1.0 rules break the HTML SGML? XHTML 1.0 effectively "plugs-in" to the underlying HTML SGML and does not redefine any of the rules regarding element usage, it simply applies the rules of XML structure to them. I'd be interested in hearing of specific examples here.

Secondly, a lot of XHTML authors reckon that if you add a few trailing slashes and an xmlns namespace to an existing document, you have an XHTML document. Ther trouble is, the vast majority of these documents contain errors, which will break the page if the correct MIME type is used.

According to the XHTML 1.0 specification "text/html" is a valid mime-type.

From W3C XHTML 1.0 Specification
"XHTML Documents which follow the guidelines set forth in Appendix C, "HTML Compatibility Guidelines" may be labeled with the Internet Media Type "text/html" [RFC2854],"

Such documents are definitively not forward-compatible, as once application/xml+xhtml is more widespread, vast swathes of current web sites using XHTML incorrectly risk to break.

Not sure what you mean by "break", can you clarify this further with an example?

Other issues include inline CSS and Javascript - if you use comment tags to hide such styles or scripts, they won't work in application/xml+xhtml documents, and putting such scripts in CDATA blocks can cause problems with backward compatibility. Also, both CSS and JS behave differently depending on the MIME type - again, breaking your page.

It is true there are some issues here but none which cannot be worked around. Your point regarding the comment (which is used to hide javascript from browsers which do not have javascript enabled) is true in the sense that an XML parser is not obliged to parse comments and therefore may or may not render them. My experience is that every parser I have played with does in fact parse comments and so this will more than likely be a non-issue. Your comment regarding CDATA can be resolved simply by keeping your scripts as external files (which is generally good practice anyway) and referring to them. E.g.


<script type="text/javascript" src="http://www.foo.com"></script>

Problem solved!


XHTML is XML, not HTML, and so you need to work in a different way. There are no advantages to using XHTML at the moment, unless you are combining it with MathML, SVG or other XML data. Better to write semantic, well-formed, validated HTML 4.01 Strict with CSS for commercial projects, and keep the XHTML for more experimental use.

Yes they are different but it is important to note that XHTML does NOT redefine any of the HTML SGML, it merely applies the rules of XML well-formedness to it (closing tags, quoted attributes, correct nesting, etc). By writing XHTML you end up writing HTML 4.01 Strict code as it is completely based upon that specification:

Quote from W3C:
The XHTML 1.0 spec relies on HTML 4.01 for the meanings of XHTML elements and attributes. This allowed us to reduce the size of the XHTML 1.0 spec very considerably.

I write XHTML pages and have very little problems doing so. Most of the time a page of mine fails to validate it is because it fails against the SGML (HTML 4.01 Strict specification). Modern browsers cope with XHTML 1.0 without any major problem and it is the road to be on for the future. If anyone has XHTML compliancy problems then post them here. I will gladly help to try and resolve them.

This 32 message thread spans 2 pages: 32