XHTML
  1. XHTML intro
  2. XHTML purpose
  3. XHTML/HTML diff
  4. XHTML syntax
  5. XHTML DTD
  6. HTML to XHTML
  7. XHTML validation
  8. XHTML modules
  9. HTML 5
  10. XHTML history
  11. XHTML summary

HTML to XHTML conversion

XHTML is the current standard and HTML is the previous. Despite this, there are still many webpages on the web that need to be converted into XHTML.

This tutorial focuses on:

Why convert to XHTML?

There is a reason, there are in fact several reasons!

NOTE: Make sure your XHTML pages have a <!DOCTYPE> declaration as the first line of code. For details about <!DOCTYPE> declarations visit our XHTML document types page.

Tag and syntax rules

To convert your pages from HTML to XHTML, there are some tag and syntax rules you need to make sure your code is following.

Tag rules

Tag rules
  • Tags in XHTML must be closed in the proper order
  • Tags in XHTML must be closed
  • Tags (as well as their attributes) in XHTML must be in lowercase
  • XHTML documents can only have one root tag

For specific details on XHTML tag rules visit our differences between HTML and XHTML page.

Syntax rules

Syntax rules
  • Attribute names must be in lower-case
  • Attribute values must be quoted
  • Attributes cannot be minimized
  • The name attribute is replaced by the id attribute
  • Some elements are mandatory

For specific details on XHTML syntax rules visit our XHTML syntax page.

Confirm page validity

Once you convert your pages from HTML to XHTML, everything is good and clean, right? Well maybe, but not necessarily. You have to actually confirm that your pages are valid.

You can do this with the validator available at validator.w3.org.

If a page validates right away, great! If it does not, it's ok. Keep working at it. If a page does not validate, the validator will tell you where the errors are so that you can fix them. Once you fix the error(s), re-test as much as you need until you get a valid page.

You can also download and use the program HTML Tidy to fix errors in your HTML code.

© Copyright 2013-2014 Landofcode.com
Terms of use | Privacy policy | Copyright information