By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more


Article comparing XHTML with HTML, and looking at the benefits.

Created: 2013-06-28 00:49

XHTML is HTML in XML, most tags and attributes are the same as of those in HTML. This Article will explain the difference, as well as briefly cover some benefits of using XHTML.

Markup Related

XHTML is not any Cleaner then a properly coded HTML page, XHTML dose not promote use of standards anymore then HTML dose.

Anyone can hold a tool, but that doesn't mean they know how to use it. Saying that XHTML is cleaner is a good sign you don't know how to use it. Yes there are many invalid HTML pages, but this doesn't mean every HTML page is invalid.

Not a Replacement

XHTML is not a replacement of HTML, and HTML will continue to be supported for a long time.


Using XHTML will not effect your placement in the search engines, other Code Related practices however might.


There is a few code-related differences, mainly empty elements needs to be closed, in addition elements and attributes must be in lowercase, and attribute values must be quoted. See also: An Introduction to XHTML

Empty elements are elements which doesn't require a closing tag, paragraphs used to be empty in earlier versions, but in later versions they require a closing tag. So empty elements would define elements such as:

br, hr, meta, img, link, base, col, area, input, frame, param

As mentioned elements must be closed in XHTML, this is done by adding a forward slash to the element, like done below.

<element />

The Document Type Definition should however not include this slash.

Document Type Definitions


The Strict Doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

The Transitional Doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

The Frameset Doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

Its also important to include the xmlns attribute on the root element, this should link to the namespace.

<html xmlns="" xml:lang="en" lang="en">

The xml namespace is used to qualify elements and attributes in XHTML.


In addition, xhtml compatible with HTML4 may be served with the text/html mime type, it should however be served as application/xhtml+xml. Future versions are expected to require the application/xhtml+xml mime type.