What is the Root Element of an HTML Document
Introduction
The tag in HTML defines the root of an HTML or XHTML page. The browser is informed that this is an HTML page via the tag. It is the second outer container for all content that follows the tag in an HTML document. Starting and ending tags are necessary for the tag.
What is HTML?
HTML stands for Hypertext Markup Language. It is the most widely used markup language for creating pages, websites, and web applications. Tim Berners-Lee proposed HTML in 1990, and W3C recommended it in 2014.
Web pages are written using HTML, which uses plain text and tags with structure to command the web browser how to display the content. In HTML, all these tags are used for page element identification, such as lists, headings, paragraphs, links, and various media and image types.
HTML tags can be empty or have two tags inside of them that carry content. An empty tag, which begins with <> and ends with, is the most prevalent HTML tag. It is also referred to as an element or an HTML element. For instance:
<html>
</html>
What is the Root Element of an HTML Document?
The HTML element is the root element of an HTML document. It is the beginning point for parsing the document and contains all other parts.
The head and body elements of the HTML element must be children.
Text and image content are found in the body element, whereas the metadata, such as the title, meta tags, and scripts, are found in the head element.
Each HTML element needs to have a start tag and an end tag that adhere to these specifications:
<html>…</html> — Starts with <html>, ends with </html>.
<head>…</head> — Starts with <head>, ends with </head>.
<body>…</body> — Starts with <body>, ends with </body>.
The entire HTML element can be empty if it has no required Meta data or content.
Example
<html>
<head>
<title>
What is the Root Element of an HTML Document?
</title>
</head>
<body style="text-align: center;">
<h1 style="color: blue;">
Javatpoint
</h1>
<p>
Example
</p>
</body>
</html>
Output
![What is the Root Element of an HTML Document](https://static.tutorialandexample.com/html/what-is-the-root-element-of-an-html-document1.png)
The head element contains the document's metadata, stylesheets, scripts, character set, title, and other elements.
It has additional metadata in addition to the head title, which is the HTML document title. A concise title that accurately summarises the page's information is ideal. It could appear in search engine results listings, the browser's tab, or window title bar, or both.
Furthermore, the head element has a description of the document, which includes its encoding character, any stylesheets being used, and any scripts used to make the document interactive.
<head>
<title>Document Title</title>
<meta name=”author” content=”Author Name” />
<meta name=”keywords” content=”Keywords” />
<meta name=”description” content=”Description goes here” />
<!- Scripts ->
<script> alert(‘Hello World’); </script>
<!- Stylesheets ->
<link rel=”stylesheet” href=”stylesheet.css” type=”text/css” />
</head>
The content of a document or application is contained in the element. Together with other objects displayed in a web browser, the body houses all viewable material, such as text and graphics.
This is the element that represents the content of an HTML document. CSS uses the body element to define its header and footer as well as to add all the elements that constitute the content of the document.
An Element of the webpage is a container of all other elements. All of your information, including text and images, should be housed in the "body" of your HTML page. Every HTML document has a body section, but it may be empty.
The element that acts as a container for all other components in an HTML document should be distinct. There is only one child in the element, which is always an element.
The usage of the tag is demonstrated in the example below:
<html>
<head>
</head>
<body>
First line <br/> second line <br/> third line <br/> fourth line <br/>
</body>
</html>
Web developers can communicate to modern browsers the structure of their HTML documents by means of doctype declarations.
An HTML page must have the doctype declaration before the root element.
It is not appropriate to validate an HTML document using the doctype declaration. This is because a web page with the incorrect doctype declaration could include erroneous HTML yet pass any W3C-conformant validator. For instance, having a <a> property or a <img> tag without an alt attribute would result in accessibility issues, yet the W3C validator will not detect these errors:
<html>
<head> … </head>
<body>
<h1>Header</h1>
<p>
<img usemap=”#map” src=”…” />
</p>
<a href=”http://www.javatpoint.com">Javatpoint</a>
</body>
</html>