The basic structure of an HTML (Hypertext Markup Language) document consists of various elements that provide the framework for creating web pages. Here’s a look at a simple HTML template with the basic components:
<!DOCTYPE html> <!-- Document type declaration -->
<html lang="en"> <!-- The root element for an HTML document -->
<head> <!-- Contains meta-information about the document -->
<meta charset="UTF-8"> <!-- Character encoding for the document -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Responsive viewport -->
<title>Document Title</title> <!-- The title of the document, displayed in the browser tab -->
</head>
<body> <!-- Contains the visible content of the document -->
<header> <!-- Typically includes the page header or site logo -->
<h1>My Website</h1> <!-- Main heading for the page -->
<nav> <!-- Navigation menu -->
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<main> <!-- Main content area of the page -->
<h2>Welcome to My Website</h2>
<p>This is a simple HTML template.</p>
</main>
<footer> <!-- Footer section at the bottom of the page -->
<p>© 2023 My Website</p> <!-- Copyright notice -->
</footer>
</body>
</html>
Here’s a breakdown of the key components:
<!DOCTYPE html>
: Declares the document type and version of HTML being used (HTML5 in this case).<html lang="en">
: The root element of the document, indicating that it's an HTML document with the language set to English.<head>
: Contains meta-information about the document, such as character encoding, viewport settings, and the page title.<meta charset="UTF-8">
: Specifies the character encoding of the document (UTF-8 is a widely used encoding for text on the web).<meta name="viewport" content="width=device-width, initial-scale=1.0">
: Sets the viewport settings for responsive design on various devices.<title>
: Defines the title of the web page, which appears in the browser's title bar or tab.<body>
: Contains the visible content of the web page, including headings, paragraphs, images, and other elements.<header>
: Typically includes the page header, site logo, and navigation menu.<nav>
: Contains the navigation menu, often as an unordered list (<ul>
) with list items (<li>
) and anchor links (<a>
).<main>
: Houses the main content of the page, such as articles, blog posts, or the primary information.<footer>
: Contains information at the bottom of the page, such as copyright notices or contact information.
This is a basic structure and we can add more elements and styles to create a complete web page. HTML is highly extensible and allows us to combine CSS (Cascading Style Sheets) for design and JavaScript for interactivity when necessary.
Thank you for reading…