Does anyone know if I can head directly for XHTML without learning HTML?
Is there a difference?

Recommended Answers

All 3 Replies

Yes, you can learn XHTML without learning HTML. You should probably learn the difference, though. With regards to the actual code, most XHTML is valid HTML, but somewhat less HTML is valid XHTML ( with some notable exceptions, i.e. a small number of HTML tags are forbidden to have a close tag, making the XHTML equivalent invalid HTML ). Other than that, there are a few differences with regard to the 'id'/'name' attributes, and XHTML is namespaced, and should be ( but rarely is ) transmitted with different content-type headers...

TBH, you'll be better off learning XHTML; the close tag rules for HTML make it somewhat difficult to write, and it's much more difficult to process automatically.

The core 'difference' is that XHTML is based on XML, and HTML is based on SGML. As it happens, XML is also based on SGML, but XML started off as a strict subset of SGML, and as such, has more neatly defined ( i.e. context-independant ) syntax rules.

XML is also a more general framework, you can mix XML languages in a single document, i.e. XML + XHTML + MathML + SVG ( all in the same file, without using external resources ), but popular browsers are only just starting to fall into line with regard to implementing these standards and others.

You can also ditch XHTML entirely and write 'pure XML' with CSS styling ( i.e. make up your own tags ), but that works in even fewer browsers.

The differences between HTML and XHTML are very complex.

There is no point in using XHTML however as the most popular browser Internet Explorer does not support it and is not likely to support it in IE8 either. Microsoft does not seem interested in support XHTML at all and ALL of the major browser manufacturers are pushing ahead with support for the intended HTML5 specification with no intention of supporting XHTML2.

Many people use XHTML as text/HTML, however this is relatively pointless as the browser simply renders the XHTML as HTML anyway. In a nutshell ... the experts recommend using HTML4 at the moment, so it is probably best to stick with that until support for either HTML5 or XHTML improves.

The differences aren't that complex. There's practically a 1-1 mapping between any ( solely ) XHTML document and an equivalent HTML document. Some of the potential XML-specific features won't be supported yet, but there's no harm in ( and it's certainly easier to ) write in the XML syntax.

All of the major browsers parse and render a document that is solely XHTML reasonably correctly; where reasonably implies that, where a browser falls down on rendering an XHTML form, it usally falls down on the equivalent HTML form. Syntactically, iIt's 'easy' to implement an XML representation if you already have a sufficiently general SGML parser, since XML syntax restrictions can be expressed in an SGML doctype; if you don't have a sufficiently general SGML parser, support can always be special-cased. Most of the browsers do one of these things. Opera and Firefox actually parse XHTML properly ( if requested to do so ), IE will just accept the syntax ( I don't know if they special-case it or not ).

Perhaps elaborate on what you mean by 'support', since it's a given that support isn't black-and-white. Your statement implies that browsers wont support any level of XHTML. Semantically, they support the level of XHTML which could be expressed at their supported level of HTML - at minimum - and sometimes more.

If speaking about pure HTML ( i.e. not considering the potential expandability afforded by mixing different XML languages in the same document ), the only noticable difference between HTML and XHTML is the syntax.

Perhaps read: http://www.w3.org/MarkUp/2004/xhtml-faq

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.