Beginning HTML5 and CSS3 For Dummies
Book image
Explore Book Buy On Amazon

The framework for a simple HTML document consists of a head and body. The head provides information about the document to the browser (and sometimes also to the web server), and the body contains content that appears in the browser window. The first step in creating any HTML document is to define its framework.

An HTML document consists of a collection of markup elements — some required, many optional — where you can always find at least three elements:

  • The opening and closing tags follow the DOCTYPE declaration and contain everything else inside the HTML document.

  • The opening and closing tags follow the opening tag. They contain definitions, labels, and information about the HTML document body that follows.

    Only certain markup elements are legal inside an HTML document head (which is another way of saying “may appear between the and tags”). The legal elements include base, link, meta, script, style, and title. (Collectively, these are known as HTMLHeadElements in the language of the HTML5 specification.)

  • The opening and closing tags follow the closing tag. They include the content and related markup for the HTML document. This is where 99 percent of the stuff that actually appears inside a web browser lives.

Any HTML markup element can appear in an HTML document body unless that element is the DOCTYPE, a major organizational container (namely, , , or ), or an element allowed only in a document head.

You could create an HTML document with no content in the , but why would you want to? It would display only a title and no other information.

Likewise, you could build a complex body with only minimal markup in the section (the </span> element is required, all other head-only elements are optional), but users and search engines that find your page might miss out on important info.</p> <p>That’s why a properly structured HTML document includes a well-constructed <span class="code"><head></span> along with an equally well-crafted <span class="code"><body></span>. For HTML documents, a body needs a head, and a head needs a body.</p>

About This Article

This article is from the book:

About the book authors:

Ed Tittel is a 30-year veteran of the technology industry with more than 140 computing books to his credit, including the bestselling HTML For Dummies.

Chris Minnick runs Minnick Web Services. He teaches, speaks, and consults on web-related topics and has contributed to numerous books, including WebKit For Dummies.

This article can be found in the category: