HTML Introduction | Getting Started with HTML | Basic HTML Structure

Basic HTML Structure

The following image shows the basic structure of an HTML document.

Basic HTML structure

<!DOCTYPE>: Specifies that the current document is an HTML document type. The HTML5 document type is <!DOCTYPE html>.

<html>: Defines the root element of the HTML document.

<head>: Defines metadata for the HTML document.

  • Metadata means information, or data, about the HTML document that is not directly displayed in the web browser.
  • This metadata can be expressed with tags such as <title>, <style>, <meta>, <link>, <script>, and <base>.

<title>: Defines the title of the HTML document and is used as follows.

  • It is displayed in the web browser toolbar.
  • When added to the browser favorites, it becomes the favorite title.
  • It is displayed as the title on search engine result pages.

<body>: The content area visible through the web browser.

<h1>~<h6>: Represents headings.

<p>: Represents a paragraph.

Types of

HTML 5

HTML 5 version.

 <!DOCTYPE html>

HTML 4.01 Strict

This DTD includes all HTML elements and attributes, but does not include presentational or deprecated elements, such as fonts. Framesets are not allowed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 "http://www.w3.org/TR/html4/strict.dtd">

This DTD includes all HTML elements and attributes, including presentational and deprecated elements, such as fonts. Framesets are not allowed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

HTML 4.01 Frameset

This DTD is equivalent to HTML 4.01 Transitional, but allows the use of frame content.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 Strict

This DTD includes all HTML elements and attributes, but does not include presentational or deprecated elements, such as fonts. Framesets are not allowed. Tags must also be written as well-formed XML.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

This DTD includes all HTML elements and attributes, including presentational and deprecated elements, such as fonts. Framesets are not allowed. Tags must also be written as well-formed XML.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Frameset

This DTD is the same as XHTML 1.0 Transitional, but allows the use of frame content.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1

This DTD is the same as XHTML 1.0 Strict, but modules can be added, for example to provide ruby support for East Asian languages.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">