I am sure, you all know about XHTML – The Extensible HyperText Markup Language. Then why I am writing about XHTML now? hm… good question!
I want to know, why XHTML is better than HTML 4.0? What is in XHTML that helps us going forward? How to convert HTML 4 documents to XHTML documents?
XHTML is an extention of HTML 4.01 and is XML based, well formed, and designed to work with XML-based user agents (like browsers).
If you have been coding in HTML 4.01 standards, you can eazily follow XHTML too.
I am just listing down the points I have noted down to write an XHTML document.
- XHTML (for that matter HTML 4.01 too), requires that you separate out presentation from content. You need to avoid using font, color and alignment tags in HTML. Instead, style sheets are preferred.
- Use title attribute everywhere. Add title attribute to <a> tags, abbreviations, and anywhere explanation helps.
- Use alt, accesskey, lang and label attributes everywhere.
- Start using id instead of name attribute. Id will help you identify the element in DOM. This is important for using style sheets too.
- Add summary tag to your table. Again, this will improve accessibility.
- Keep all the tags in lowercare
- Close and correctly nest all tags
- Close empty tags using space /> like <br />
- XML does not support attribute minimization. Attribute-value pairs must be written in full. For example, wrap=”wrap” is required to specify word wrap.
- Use double quotes to specifiy values to attributes, like border=”1″
- Embed style sheets and scripts in CDATA section.
- Avoid line breaks and multiple white space characters within attribute values.
- Use both the lang and xml:lang attributes when specifying the language of an element. The value of the xml:lang attribute takes precedence.
- make sure that, XML namespace and DOCTYPE lines at the beginning of the page
It is important to use CSS in conjunction with XHTML to produce consistant web pages.