Not a member? Why not join us or log in? (No more hassle filling in comments, less obtrusive ads and asides.)

The Invisible Design Decision

Posted by Abhijit Nadgouda on November 2nd, 2006.

A software professional who believes that every bit(!) of software written should serve a purpose for the customer.

http://ifacethoughts.net/

Abhijit Nadgouda has posted 6 articles.

RSS Feed for fadtastic.net RSS Feed for Abhijit Nadgouda

Full Profile →

Most of the elements of our design are visible on the screen, from information architecture and design to the graphics. However, dealing with technology usually involves making some invisible decisions that impact the entire design. One of the such important decision is deciding between HTML and XHTML. It is one of those decisions which have to be taken right at the beginning.

XHTML has always been considered as a successor of HTML - a newer model, a new version that improves over the older. Which is what tempted a lot of web people, including yours truly, to start with XHTML. However, as we will see, using XHTML comes with additional responsibility and effort.

What Is XHTML?

You might have come across this question a zillion times before. However, at the cost of repetition, I would like to answer this question again.

XHTML is a family of current and future document types and modules that reproduce, subset, and extend HTML 4 [HTML4]. XHTML family document types are XML based, and ultimately are designed to work in conjunction with XML-based user agents. The details of this family and its evolution are discussed in more detail in [XHTMLMOD].

The X in XHTML stands for ability to extend HTML to make it more functional and interoperative with other markup languages. To be able to do this, XHTML has been based on XML as against SGML.

Pros of XHTML

XHTML derives all the benefits of XML. The important one is that it enforces separation of data and style. This can be done equally efficiently with HTML too. The difference is that XHTML enforces it since HTML is a presentational markup language, where presentational elements are part of the markup.

Another aspect of XML is extensibility. It can mashup with other XML-based markups, like MathML and SVG, and provide a single uniform document. This interoperability between different markups provides for easier automation.The requirement is, as it is with HTML, that it should be associated with the right DTD which can be used for validation.

XHTML has a benefit for developers for debugging. To parse a XHTML document it has to be well-formed XML, that is, it abides by all the rules of XML. This can be helpful for catching errors early in the cycle.

Responsibility with XHTML

XHTML sounds like one the best things to happen. It is true to some extent, but not without more responsibility and effort. The pros of XHTML mentioned will stand good only if

  • The strict doctype is used
  • It is served as appliction/xhtml+xml

Let me elaborate on both these points.

The Strict Doctype

This point is important even if you decide to use HTML. A doctype is a Document Type Declaration which declares type of the document it resides in. It is metadata about the document that can be used by softwares like browsers and validators to verify if your document is structured the way you have declared it to be. It does so by including path to the intended DTD. This is important because some softwares, like browsers, might change their behaviour depending on this.

Ideally, only the strict doctype would have been enough and it is what is recommended whenever a new web page is designed. An additional transitional doctype is supported for upgrading the legacy web pages to the new standard. Transitional is more lenient as it allows space for upgrades, is inherently temporary and so should not be used for new web designs. However, this has not been heeded well by the community. We have thousands of new web designs which declare themselves to be HTML/XHTML transitional compliant. Roger Johansson has explained nicely difference between the two doctypes.

The application/xhtml+xml media type

W3C has defined certain media types that should be used with corresponding documents in the XHTML family. They are text/html, application/xhtml+xml, application/xml and text/xml. The browser identifies the content type using these and treats the content accordingly. For example, text/html says that the content is html, application/xhtml+xml says that it is XHTMl and so on. text/html is recommended for using with HTML documents and not with XHTML family documents. The application/xhtml+xml is recommended for XHTML documents. So far so good!

The trouble here is that many browsers today, including the widely used Microsoft Internet Explorer do not support this content type. Meaning that if you try to load a XHTML document which is being served as application/xhtml+xml the browser will not understand it and may ask you to save the document. So a lot of XHTML documents today are served as text/html. This makes the browser treat your XHTML document as plain HTML with some incompatibilities. Ian Hickson elaborates on the dangers of serving XHTML documents as text/html.

For designers, XHTML documents that pass validity with being served as text/html can miserably fail when served as application/xhtml+xml. Which means that they are truly not XHTML.

Myths

I have come across certain myths about HTML, XHTMl and CSS.

  • HTML does not work with CSS. This is one of the common reasons given for using XHTML. HTML can be used, just that it is easy to not use CSS too, which might break the data-style separation principle.
  • XHTML Transitional is better than HTML. Any form of transitional doctype is not good for new web designs. Their intent is to be used with migrating legacy designs, not for anything else. In fact HTML Strict is much better than XHTML Transitional.
  • XHTML is just HTML with closed tags. This is used a lot of times to convince others that migrating to XHTML is easy. Syntactially XHTML can be seen as XML applied on HTML, but it is not so. The allowed elements will depend on the doctype used, and the Strict doctype will not allow a lot of HTML elements and attributes. The browsers too treat parsing of CSS and JavaScript differently for HTML and XHTML documents.
  • XHTML is stricter than HTML. This is true theoretically, but practially when XHTML is served as HTML this turns into a myth. The only strictness can apply in the well-formedness. Also using the Transitional doctype will allow you to use presentation markup in XHTML, overriding the purpose of XHTML.
  • HTML is going to die. This has been busted by the recent news from W3C about parallel HTML and XHTML existence.

Epilogue

Your decision to go with HTML or XHTML should be justifiable. Each have their pros and cons, and migrating either way in the later stage can burn a hole in your client’s pocket. I have faced situations where I wanted to go with HTML, but also wanted to be ready to move to XHTML if required. The meta information can be updated then. However, to make a possible move to XHTML in future easier I have used HTML with closed tags.

Overall, this is a subjective topic and every designer has formed his/her own opinions and conclusions. Somehow I feel that there needs to be best practices or recommended practices for situations like these. Otherwise there might be cases when the standards might just be treated as preferences and make the Web incompatible.

Interesting reading:

Make A Comment

( 28 so far )

blockquote and a tags work here.

28 Responses to The Invisible Design Decision

Comments RSS Feed

HTML is doing to die!!! Oh no!!!…wait….doing to die?

FrankieB
November 2nd, 2006
#

Yes, finaly. I don’t see why so many people use XHTML, and sends it of as text/html. Why?

Tor Bollingmo
November 2nd, 2006
#

I have to admit I’m guilty of switching to XHTML without really fully knowing its uses and capabilities. Great intro, Abhijit.

Andrew Faulkner
November 2nd, 2006
#

FrankieB, quite an hilarious comment to point out an equally hilarious typo. Thanks, it has been corrected.

I too have treaded the wrong path, but IMHO this information was not as publicized as the rest about XHTML. The reason might have been that the information was too technical for a lot of guys to read and digest it. That is why I feel that recommended practices, like a short reference, should be available for this.

Abhijit Nadgouda
November 2nd, 2006
#

[…] My digging into the HTML v/s XHTML debate led me to write my latest article on fadtastic - The Invisible Design Decision. I had read a lot on this, but took some time to digest it. However in the light of new development from W3C, you might give a second thought to your decision to go with HTML or XHTML. What do you think? […]

[…] The Invisible Design Decisions - Another great artcile on XHTML. […]

Designing for XHTML is very usefull server side…

I deal with ASP/.NET technologies and use lots of XML based technology - stuff like SQL Server’s XML extensions / RSS / XML-RPC / XSLT / SOAP etc.

Keeping the output format of my scripts as XML allows me to serve the data directly to the client as XHTML, use it as a SOAP response or use it elsewhere without the need to convert to other formats. Infact, the final XHTML output could be loaded directly into a XML parser and used as a datasource.

It would be great if the MIME type of ‘application/xhtml+xml’ was supported in IE but, IMHO serving a well formed XML document as text/html is still much more usefull than HTML since it’s still an XML document and I can treat it as such.

Keith
November 3rd, 2006
#

I agree Keith that XHTML will help a lot if it is going to be used as XML anywhere else. In fact, that is the intent of using application/xhtml+xml which declares that the content is valid XML along with being XHTML. The problem is that text/html is fine only upto XHTML 1.0. If you upgrade to XHTML 1.1 then text/html has to be completely avoided since XHTML 1.1 is not HTML compatible.

As a discussion, would HTML with closed tags work as well formed XML? I am not sure what mechanism you are using to use the XHTML as XML elsewhere since you might have to change the namespaces to use it for stuff like SOAP response.

Abhijit Nadgouda
November 3rd, 2006
#

Abhijit, That would make an interesting discussion..

In it’s most simple form XML is a text document so as long it compiles with the W3C XML Spec. you can use it as an XML document.

Technically, you could serve a document as ‘text/plain’ as long as it meets the XML spec. you can load it into an XML parser as a string and use it. BUT… doing this means the user-agent must work out that your using XML itself - this is where setting the correct Content-Type header comes in.

Just closing tags isn’t enough to make HTML XHTML…

XHTML 1.x is a subset of XML and is therefore natively XML compliant. As you point out in your HTML is a subset of SGML which can be XML compliant but, as the HTML Spec. is so flexible its usually not just as simple as closing your tags - things like DTD’s, Entities, CDATA Sections etc. must also be considered.

Keith
November 3rd, 2006
#

Yes, its true that XHTML is not just HTML with closed tags, in fact I have found that it is one of the popular myths. However, is it possible to close tags in HTML to form well-formed XML, not XHTML? So we can serve the document as HTML to the browser, and can use it as XML elsewhere.

Abhijit Nadgouda
November 3rd, 2006
#

Yes and No. If we’re planning to serve a document as HTML 4 with an HTML 4 DTD then we can’t just close tags to make a valid XML document. Self closing tags are not part of the HTML 4 spec but they are required in XML. Using self closing tags in HTML would probably cause validation issues (I’ve not checked that tho’)

This is why I serve XHTML 1.0 - I can use XML techologies to create / manipulate a document and still serve it as ‘text/html’ with an XHTML 1.0 Strict DTD.

A few years ago I couldn’t have justified the switch to XHTML but in a world of Content Syndication and API’s having the ability to load well-formed web based content (be it RSS, SOAP messages or an entire web page) directly into an XML parser is a powerful tool.

Keith
November 3rd, 2006
#

I guess i could summarize it like this…

HTML has a very specific job. Its exists to instruct user-agents on semantics. These can the be used for indexing (A search engine) or used for display purposes (a browser)

XML is essentially a data description langauge, its very formal which makes it very portable. It’s used extensivly in communication over the web.

XHTML is both!

I think the real issue with choosing between HTML and XHTML lies with understanding how the XML part can be of advantage to you - I’d hazard a guess that most web developers don’t fully appreciate or even need the extras XML offers which basically renders XHTML a different way of writing HTML. Maybe that explains why there is confusion over which to use…

Keith
November 3rd, 2006
#

I think the real issue with choosing between HTML and XHTML lies with understanding how the XML part can be of advantage to you - I’d hazard a guess that most web developers don’t fully appreciate or even need the extras XML offers which basically renders XHTML a different way of writing HTML. Maybe that explains why there is confusion over which to use…

I think you hit the nail on the head there.

Andrew Faulkner
November 3rd, 2006
#

Yes, I missed that. So, trying to a build valid HTML document as a well-formed XML goes out.

Abhijit Nadgouda
November 3rd, 2006
#

Right on the point Keith.

Abhijit Nadgouda
November 3rd, 2006
#

escaping special characters can be a problem when using XHTML 1.0, especially when using server-side statements in your hrefs, for scripts and stylesheets you have the CDATA comments to wrap around your code in XHTML pages. A useful article, see about middle of page: see here

Johan
November 3rd, 2006
#

Great article. It’s really got me thinking about the importance of choosing a Strict doctype when I start building a new website. I am one of those web designers who has lazily (or naively) continued to use a Transitional doctype when I should have switched to Strict by now.

Even if many web designers don’t need really need all of the advantages of XHTML, the fact that XHTML makes a requirement out of many of HTML’s ‘best practice’ recommendations has vastly improved the overall quality of my markup. And the advent of markup validation tools has helped me to detect markup problems that used to just fly under the radar. Now all I need to do is go Strict!

Jonathan Nicol
November 3rd, 2006
#

@Jonathan Nichol, you can use HTML 4.01 strict or XHTML 1.0 strict.

More info: Understanding HTML, XML and XHTML

Johan
November 3rd, 2006
#

Great article Abhijit! Pitched at the right level and providing a great overview. Thanks for sharing.

Steven Tew
November 4th, 2006
#

Johan, yes there will be more efforts with the decision to go with XHTML. That is the reason the decision should be justified, like in the case that Keith mentions.

Thanks for the comments guys. I am learning a lot from the discussion here.

Abhijit Nadgouda
November 4th, 2006
#

Hi, I also switched over to XHTML as it seemed to me to be the next thing after
HTML.

I found that everyone else was using it, so it seemed logical.

Great Article

Daz

Darryl Remnant
November 6th, 2006
#

[…] This is very interesting, it seems HTML 5 is acknowledging the Semantic Web, which was done using the divs. I think eventually usage of div will reduce, I am not sure if it can be completely eliminated. This can strong impact choosing HTML or XHTML for your web site. I am not sure if these elements will be built into the XHTML versions too. If not would HTML 5 be considered more semantic? I wonder if these things will be addressed in the specification being worked upon. […]

[…] fadtastic, The Invisible Design Decision […]

[…] I had tried to find out about selecting HTML or XHTML, and why there was no urgency towards serving the recommended content type. It is not very easy to find websites where this is done successfully. One popular reason is very clearly explained by Ajay. Shelley Powers points out that it is important to educate the experts about benefits of the technology behind this. […]

[…] The Invisible Design Decision […]

surely nobody is using html anymore?

jim
July 1st, 2008
#

[…] Ian Hickson has more on the dangers of serving XHTML documents as text/html. Fadtastic has more on HTML vs. XHTML. […]

Пока успел прочитать только эту одну заметку, если и все остальное также хорошо, то автору респект :)

Эрик
July 22nd, 2009
#

↑ Jump up to the comment form

Related In Some Way, Shape Or Form

The above post has obviously kept you amused. Why not discover similar material:

The posts Competition: Free Ad or Money!The end of an era for Times New Roman?Who To Design For?Are Gradients Great?The Unknown Blogger and First Impressions, are related to this post.

Or why not take time out to find out about the author of the post.