XHTML - Transitional vs Strict

XHTML Transitional vs XHTML Strict. When to use what?

One of the dilemmas a web developer meets along the way is which Document Type Declaration to use for their website projects which as some extent, affect how your document content is indexed by search engines and is displayed in different browser. But to set things straight, whether or not you use HTML or XHTML doesn’t matter for as long as you declare if you will use Transitional or Strict.

Definition of Terms

TRANSITIONAL DOCTYPEs are meant for those making the transition from older markup to modern standards. It may be used for elements and attributes that cannot be easily converted into complying with the Strict DOCTYPE.  It is more flexible in way that it allows you to use presentational elements like <font> and <center> and is allowing you to keep some of the unclosed tags such as <p>.

STRICT DOCTYPEs on the other enforces the separation of structure (html) and presentation (css). It excluded all elements and attributes that are already deprecated or can be manipulated through the use of css such in the case of <div align=”center”> which can be achieved with “text-align: center” in css. Aside from the separation of structure and presentation aspect, Strict Doctype also enforces the proper closing of elements and proper enclosing of attributes to a pair of quotation marks or single quote such as “<p></p>” and “<p class=’headlines’></p>”. At some point, Strict is also particular with some of the attributes value such in the case of the <img> tag which you can’t declare without the “title” and “alt” attribute.

For most, they preferred the STRICT Doctype (regardless if it is HTML or XHTML) because this will separate your structure from your presentation which can make your code future-proof. With this, you can easily change the behavior of your elements in the Cascading Stylesheet. This also promotes a more semantic structure and ensures that browsers will use their strictest standard compliant rendering modes.

However, if you decide to use STRICT doctype, you have to be cautious with your tags and attributes and make sure that it complies with the W3C standards for STRICT document types; else, your document will be marked with errors and might not render correctly such in the case of Internet Explorer.

Here are some of the things that you should consider:

  • Deprecated Elements are already invalid such as <center>, <font>, <strike>, and <u>. These elements can be manipulated in your stylesheet.
  •  Presentational Attributes are not allowed, declare it in the stylesheet such as “background”, “alignment”, “border”, “width”, “height”, “links” and “vspace”
  •  Elements must be properly nested (not just in strict doctypes but in all html documents)
  •  text and images  must be contained in a block element like <p> or <div> and must not immediately appear after the body tag
  •  wrap text in <p> or <div> if it is a blockquote

DTD, whether it is STRICT or TRANSITIONAL, does not directly affect how your website is index by search engines or how your browser displays your contents. It will just make your code more structuralized complying with semantic standards. But regardless of the DTD, it is always a good practice to get the structure right before thinking of the presentation of elements.



24 Ways – http://24ways.org/2005/transitional-vs-strict-markup

Web Master World – http://www.webmasterworld.com/forum21/9939.htm

Stackoverflow – http://stackoverflow.com/questions/1885906/xhtml-1-0-transitional-vs-xhtml-1-0-strict

Sitepoint – http://www.sitepoint.com/forums/showthread.php?272007-XHTML-Strict-vs-Transitional

Leave a Reply

Your email address will not be published. Required fields are marked *