Home

HTML5 Document Organization Revisited

|
Updated:  
2016-03-26 14:03:43
|
HTML5 and CSS3 All-in-One For Dummies
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 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.

That’s why a properly structured HTML document includes a well-constructed along with an equally well-crafted . For HTML documents, a body needs a head, and a head needs a body.

About This Article

This article is from the book: 

About the book author:

Ed Tittel is a 28-year veteran of the computer industry. A seasoned author and consultant, Ed has more than 140 books to his credit.

Chris Minnick is an accomplished author, teacher, and programmer. Minnick authored or co-authored over 20 books, including titles in the For Dummies series. He has developed video courses for top online training platforms and he teaches programming and machine learning to professional developers at some of the largest global companies.