Page Index


HTML and XHTML are both languages that are used to inform web browsers, such as internet explorer, firefox, or safari, how content should be displayed on a web page. Using XHTML, you can control things like color, font, and layout of a page that you put onto a website. This section is intended to teach you how to use XHTML to build a simple website.


While HTML and XHTML seem quite similar, there are a few key differences that distinguish the two markup languages. Essentially, XHTML incorporates XML into standard HTML documents, which makes the exchange of information easier to process and maintain. The primary differences between the two is that XHTML requires well-formed syntax. All tags to be closed and in lowercase, unlike in HTML. In addition, all XHTML elements must be properly nested and well-formed, which means that all elements must be nested within the <html> root element and sub elements must be in pairs.

The increase in the use of portable devices, such as PDA's and internet-capable cellular phones, has made it necessary to reduce the complicated syntax of HTML in able to deliver Web information to them, which have more constraints than PC's. Because it is necessarily well-formed, XHTML does not require a custom parser like HTML does.

Using Markup Tags

An XHTML file is a text file that contains a series of small markup tags. These markup tags are responsible for telling the Web browser how to display the information on the page. XHTML tags are surrounded by the two characters < and >. Typically, XHTML tags are presented in pairs, such as <b> and </b>. The basic XHTML page will consist of a start tag and a closing tag. While it is not necessary to include closing tags in HTML, it is required in XHTML. The text or information that is between the start and closing tags is referred to as the element content.


The following code, then, will display the text 'This text will be bold' as bold:

<b>This text will be bold</b>

Here, the XHTML tag begins with the start tag <b>. The content of this XHTML element is This text will be bold. The XHTML element then concludes with the closing tag </b>. The purpose of the <b> tags is to define an XHTML element that should be displayed in the browser as bold. In HTML, tags are not case sensitive and <B> means the same as <b>. However, XHTML requires the use of lowercase tags.

Common tags

The most important tags in HTML and XHTML are tags that define headings, paragraphs and line breaks. Below is a list of basic XHTML tags:

More on HTML and XHTML tags.

Common Errors

The strict syntax requirements of XHTML result in cleaner documents, but are less forgiving of sloppy commands or "tag soup" that passed with HTML. Both experienced HTML users and those with no prior knowledge to XHTML can run into specific problems while getting acquainted with XHTML. The following information serves as a troubleshooting reference should a document not transfer well online.

  1. Using caps in commands: although not a problem with HTML, lowercase commands are detrimental to XHTML.
    • Incorrect: <B>boldface</B>
    • Correct: <b>boldface</b>
  2. Nesting Elements in Incorrect Order: commands must enclose the immediate text which they are being applied to.
    • Incorrect: <h1><b>Title!</h1></b>
    • Correct: <h1><b>Title!</b></h1>
  3. Not closing elements: XHTML requires that closing tags always be used, to insure compatibility with CSS.
    • Incorrect: <p>Text<p>More text
    • Correct: <p>Text</p><p>More text</p>
More on common errors

Validating XHTML

Markup Validation is used to check Web documents in formats like HTML and XHTML for conformance to browser compatibility and other standards noted by World Wide Web Consortium (W3C). All webpages that are published should be validated, to ensure that the code is structured properly. Documents which do not follow certain standards may not be rendered correctly depending on the browser receiving and interpreting the information. Therefore, simply testing the page by viewing it on a single browser, or even on a number of browsers using the same operating system, does not mean that the page will display properly on other browsers and other operating systems. Any website published for the purpose of sharing information (rather than for storing information solely for oneself) is optimally operational on a multitude of pages. On sites published to a very large audience, it is even advisable to test the page on multiple browsers using multiple operating systems in addition to validating the pages.

The W3C Markup Validation Service

Limitations of HTML

While HTML has accomplished a number of important tasks in the past, it seems as though it has become inadequate for modern Web use. HTML is excellent for formatting the display of a web page, but it is not capable of handling the processing needs of an information application. Most HTML documents are bulky with unnecessary code, which makes it difficult to create pages that are compatible with non-conventional platforms such as handheld devices.

Other HTML limitations include:

User Contributed Notes
E-MELD School of Best Practices: About XHTML
+ Add a comment
  + View comments

Back to top Credits | Glossary | Help | Navigation | Site Map | Site Search