Learn something new every day More Info... by email
The eXtensible HyperText Markup Language (XHTML) has replaced the similar HyperText Markup Language (HTML) as the markup language of choice for creating webpages, but old webpages are relatively easy to convert from HTML to XHTML. First, choose the appropriate version of XHTML to convert to because different versions support different features. Then make changes to the code by hand to better understand the new language’s syntax rules or use a software tool to convert pages for you. In either case, it is a good idea to check that the document was converted properly with an XHTML validator, which can detect any errors in the code.
Keep in mind that just like HTML, XHTML has several different versions, and not all of them support the same features. XHTML 1.0 Transitional allows certain presentational tags, elements, and attributes present in earlier HTML standards including the <font> tag and "center" attributes. If you’re moving from HTML to XHTML 1.0 Strict or XHTML 1.1, remove any any presentational tags or elements and recreate the desired look using Cascading Style Sheets because these versions of XHTML do not support any presentational elements.
For a simple web document, it's possible to perform an HTML to XHTML conversion by hand. If you're new to XHTML, this may also help you become more familiar with the stricter syntax rules of the language. To conform to these stricter requirements, make sure that all tags are in lower case, properly nested, and closed with a forward slash. In addition, all values must be inside quotation marks. The “find and replace all” option available in most text editors and web development programs can help you make these changes.
Software can also convert your code from HTML to XHTML with just a few clicks. Most professional web design programs have this option, often under the “File” or “Tools” menu. A popular tool called HTML Tidy, originally released by members of the World Wide Web Consortium (W3C), can be downloaded for free and will both clean up and convert between popular web formats. You might also be able to find a few tools online that can change documents from one markup language to another.
Whether you choose to edit your documents by hand or use software to perform the HTML to XHTML conversion, there are a few things you should check before publishing your pages to the web. To be valid XHTML, a page should have both a Document Type Definition (DOCTYPE or DTD) and an XML namespace declaration. Each of these will depend on what version of XHTML you use, so do a little research to figure out what these elements should look like. An XHTML validator, available within most web development software as well as on the W3C’s website, will inform you of any errors or omissions in your code.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!