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?
- Tag and syntax rules
- Confirm page validity
Why convert to XHTML?
There is a reason, there are in fact several reasons!
- Pages will be up to date - XHTML is the modern standard, HTML is the previous. By converting your pages to XHTML, you are showing that you are up to date on web standards.
- Cleaner, more efficient code and better usability - By converting your pages to XHTML, you will have cleaner, more efficient code since you will be clearing out any mistakes (such as a missing closing tag) that may result in a page not displaying correctly. By doing so, you will at the same time provide better usability for your webpage visitors because you will be insuring that they see your pages how you intend for them to be seen.
- Pages will validate with a webpage validator - By converting your pages to XHTML, they will validate with a webpage validator (assuming you use correct syntax and don't break any tag rules). Validated pages show that you have taken the time to create interoperable content that will be displayed as intended on various browsers and devices.
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.
For specific details on XHTML tag rules visit our differences between HTML and XHTML page.
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.