HTML document structure
HTML document is basically separated in two segments: the head (HTML head element) and the body (HTML body element), both contained by the 'HTML' element. You add a Document Type Declaration on top of it and get the basic document structure for a web page.
The !DOCTYPE declaration:
Every well-written HTML document begins with a basic declaration that defines what type of document it is. This declaration is made using the HTML! DOCTYPE tag and is the very first thing in all the document. It's intended to tell the processing agent (e.g., browser, search engine, etc.) for which standard is designed the document that's about to process.
A normal declaration for a document written according to the XHTML 1.0 Strict standard should look like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
The content of the HTML element can be basically Divided into two parts: the head (HTML head element) and the body (HTML body element).
You May Also Like
Features of HTML
HTML Formatting Tags
Different Types of Lists in HTML
Tables in HTML
The Document's Head:
The head of an HTML document acts as a container for particular information that's defined through a set of elements. All the information contained in the document's head is loaded first, before any other thing in the document, as it's defined before the body segment.
An HTML document's head is enclosed by the HTML head element and can contain some of these element definitions:
• Document's Title: Describes briefly what the document is about.
• Style Declarations: Group of class definitions (style sheets) used by other tags to set visual characteristics. Read more at the HTML style element reference.
• Script Functions: Set of functions declared inside the HTML script element to provide functionality to the document.
• Meta Statements: Declared through the HTML meta tag, set custom attributes and values for the document.
• Global links: Defined using the HTML link tag designates resources related to the actual document.
Here is an example of the basic HTML Programs document's head using the previous elements:
<head>
<title>The HTML code explained</title>
<meta name="keywords" lang="en" content="HTML, code, explanation" />
<meta name="description" lang="en" content="Explanation of the HTML code." />
<meta name="Author" content=" Robert" />
<style>
table {
border-width: 100%;
border-color: black;
}
</style>
<script>
function sum(amount) {
result += amount;
}
</script>
<link rel="index" href="/../index.html" />
<link rel="print" href="/printer.html" />
</head>
The Document's Body:
The body is the container for the visual part of a document. All the things written here will be shown when the document is finally rendered. Most of the tags in HTML can be inserted in the body section (inside the HTML body element) and will shape the visual aspects of the document.
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
The attributes of <body> tag are as follows:
Background: It is used to specify the URL of a background image. This attribute is now deprecated.
Text: It is used to specify the text color. This attribute is now deprecated.
Link: It is used Specify the color of unvisited hyperlink text. This attribute is now deprecated.
VLink: It is used to specify the color of visited hyperlink text. This attribute is now deprecated.
ALink: It is used to specify the color of active hyperlink text (i.e. when the user clicks on it). This attribute is now deprecated.
You May Also Like
HTML Css(Cascading Style Sheets)