You are here:About>Computing & Technology>Web Design / HTML> HTML and XHTML> Beginning HTML Tutorials> Basic (X)HTML Tags for a Web Site
About.comWeb Design / HTML
Newsletters & RSSEmail to a friendSubmit to Digg

Basic (X)HTML Tags for a Web Site

From Jennifer Kyrnin,
Your Guide to Web Design / HTML.
FREE Newsletter. Sign Up Now!

Every Site Should Have These Tags

These are the tags required in every Web page. (Note: some are not technically required by the HTML specification, but some browsers will not render correctly without them, so it is always better to leave them in than out - the space you save is not worth the problems you might cause.)

<!DOCTYPE>
The DOCTYPE element is not really an XHTML element, but rather an identifier for the page. In order to create a valid XHTML document, you need to include the DOCTYPE. The DOCTYPE references a DTD, and there are three DTDs you can use:

  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    This is the strict DTD, I wouldn't recommend using this DOCTYPE unless you plan to be very careful with your XHTML
  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    This is the transitional DTD; it is the best one to use for most Web sites
  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    This is the frameset DTD; if you're going to put up a framed page, you should use this DTD

<html>
The first tag that any Web page must have is the <html> tag. It tells the browser that the following text will be marked up in HTML format, and not some other format such as straight text, SGML, or XML. The closing tag </html> is required and is the last tag in your document.

<head>
The <head> tag is used to define information for the browser that may or may not be displayed to the user. Tags that belong in the <head> section are <title>, <meta>, <script>, and <style>. The closing tag </head> is required.

<title>
The <title> tag belongs in the <head> section of your document. It is the title of your Web page, and is usually displayed by the browser at the top of the browser pane. The closing tag </title> is required.

<body>
The <body> tag is where all your HTML information belongs. It defines the primary portion of your Web page. With attributes of the <body> tag, you can define the background color of your Web pages, the text color, the link color, and the active and visited link colors. The closing tag </body> is required.

A sample Web page would look like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>
  This is the title of the page.
</title>
</head>
<body>
  The body text goes here.
</body>
</html>

Learn more about these and other tags in the HTML Tag Library.

 All Topics | Email Article | | |
Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.