News & UpdatesProgrammingWeb programming Store My Projects
Links
Affiliates

HTML Tutorial – 18 – Standards

Every HTML document should begin with a reference to a Document Type Definition (DTD), or doctype, to be standard compliant. This definition declares which version of the HTML standard that the document follows and must be placed before the <html> element. The three versions defined are: strict, transitional and frameset.

Strict definition

The strict definition includes only the structural markup without any of the deprecated elements or attributes. Instead, it leaves formatting up to CSS.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/HTML4/strict.dtd">

Transitional definition

The transitional definition includes everything that is deprecated and is intended to smooth the transition over to the strict definition.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/HTML4/loose.dtd">

Frameset definition

The frameset definition is used by frame documents. It contains the same elements as the transitional definition, except that it includes the frameset elements.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/HTML4/frameset.dtd">

XHTML definitions

There are corresponding versions for XHTML documents.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Meta tag

Another standard that should be followed is to include metadata in the document, using the <meta> header tag. The tag requires either the name or http-equivalent attribute, paired with the content attribute. The http-equivalent attribute will cause the metadata to be sent as HTTP header information. The most important metadata is the document’s file format and its character encoding.

<meta http-equiv="Content-Type" 
content="text/HTML; charset=iso-8859-1">

For XHTML documents another MIME type and subtype are used.

<meta http-equiv="Content-Type" 
content="application/xhtml+xml; charset=iso-8859-1" />

Metadata can also be used to help search engines by providing a description of the document and a list of keywords relating to its content.

<meta name="description" content="document description">
<meta name="keywords" content="list, of, keywords">

Another common use of the <meta> tag is to automatically redirect a visitor to a new page after a specific number of seconds.

<meta http-equiv="refresh" content="0; url=newpage.html">
Recommended additional reading:
Sams - Teach Yourself HTML and CSS in 24 Hours