Difference between revisions of "Basic HTML Document Structure"
(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== ...") |
|||
Line 21: | Line 21: | ||
===The Doctype Element=== | ===The Doctype Element=== | ||
− | All HTML pages should have a <code><doctype></code> declaration that informs the browser which version of HTML the page is written in. See [[Doctype]] for | + | All HTML pages should have a <code><doctype></code> declaration that informs the browser which version of HTML the page is written in. See [[Doctype | doctype]] for more information, as well as a list of available doctypes. |
===The HTML Element=== | ===The HTML Element=== |
Latest revision as of 21:53, 17 November 2013
All HTML documents must adhere to the same basic structure. There are some variations between the different versions of HTML, which are described below.
Contents
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 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.