HTML versus XHTML

For our purposes, we can think of XHTML as a strict form of HTML. Since it came into use after many years using HTML, all browsers accept both. HTML is fine for our class, but, if you build a Web site that you expect to be used for many years in the future, the few extra keystrokes to conform to the XHTML standard are worthwhile.

Here are some of the key differences between XHTML and HTML (there are more differences, but these are common ones):

Additionally, you should place the following in the Head section of an XHTML document in order to specify which language and "vocabulary" you are using: <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> (If you are curious, you can see the codes for languages other than English here).

For a concrete example, here is the same page marked up in HTML and XHTML. They are both rendered exactly the same by the browser, but, if you view the source of each page, you will see that the XHTML version complies with the restrictions listed above.


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.