SJHwebdesigns

Required Tags

« Previous: HTML Basics | Next: Common Formatting Tags »

These tags must be included in any HTML document in order for it to be valid HTML. They define the basic structure of a web page.

<!DOCTYPE>

The document type declaration goes at the very start of an html document; it tells the browser which version of (x)html the document is written in. For XHTML 1.0 Transitional, the doctype is:

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

Including a DTD helps your pages to display more consistently and predictably across browsers. Don't mind too much about what its innards actually mean at this stage; for the time being you can just copy this into the top of every page you make without worrying about the grisly details.

<html>

This element tells the browser that this is an HTML document. The start tag follows the doctype, and the end tag goes right at the end of the document.

<head>

The head element can contain information about the document. The browser does not display this information to the user (apart from the contents of the <title> tag). This element goes immediately after the <html> start tag.

<title>

This element defines the title of the document. It displays in the title bar at the top of the browser.

<body>

The body element contains all the contents of the document (text, images, colours etc). Only content within this element will display in the browser window. The body element goes just after the head element.

Note that each document must have one head and one body, in that order; everything else in the page must be contained within those two tags.

Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title>My Page</title>
   </head>
   <body>
      Contents of my page...
   </body>
</html>

« Previous: HTML Basics | Next: Common Formatting Tags »

Page style: Dark Light