Member-only story
Basic structure of HTML document
For more questions and answers visit our website at Frontend Interview Questions
Basic Components of an HTML Document
An HTML document consists of several key components that work together to define the content and layout of a webpage. Here’s a breakdown of these components:
- Document Type Declaration (
<!DOCTYPE html>) - Root Element (
<html>) - Head Section (
<head>) - Body Section (
<body>
1. Document Type Declaration
Purpose: The <!DOCTYPE html> declaration defines the document type and version of HTML being used. It helps the browser understand how to render the document correctly. For HTML5, this declaration is straightforward and does not include a version number.
Example:
<!DOCTYPE html>Explanation: This declaration indicates that the document is an HTML5 document.
2. Root Element (<html>)
Purpose: The <html> element is the root of an HTML document. It contains all other elements and encapsulates the entire webpage.
Example:
<html>
<!-- Head and Body sections go here -->…








