This wiki is for the exclusive use of my friends and colleagues. Account creation and anonymous editing have been turned off.

If you are a friend or colleague of mine, and would like to participate in this project, please send me a message.

If you find these pages useful, please donate to help cover server costs. Thanks!

Basic HTML Document Structure

From OdleWiki
Revision as of 19:13, 17 November 2013 by Kenneth John Odle (talk | contribs) (Created page with "All HTML documents must adhere to the same basic structure. There are some variations between the different versions of HTML, which are described below. ==Basic Structure== ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

All HTML documents must adhere to the same basic structure. There are some variations between the different versions of HTML, which are described below.

Basic Structure

The basic structure of any HTML document, whether HTML4, HTML5, or XHTML, is the same:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Document Title</title>
</head>
<body>
...[page content]...
</body>
</html>

Differences Between HTML Versions

The Doctype Element

All HTML pages should have a <doctype> declaration that informs the browser which version of HTML the page is written in. See Doctype for a more information, as well as a list of available doctypes.

The HTML Element

For HTML4 and HTML5 documents, this is simply <html lang="en">. For more information, see Language Codes.

The Character Encoding Element

This is the charset meta element. An HTML4 document doesn't have the trailing slash, whereas an HTML5 document may or may not have the trailing slash. It's preferable to put it before the title element.