HTML Examples

A collection of practical HTML examples to help you understand how to structure your web pages.


Basic HTML Document

This example demonstrates the fundamental structure of an HTML5 document. All HTML documents must start with a document type declaration: <!DOCTYPE html>.

The visible part of the HTML document is between <body> and </body>.

Example Code

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My First HTML Page</title>
</head>
<body>

    <h1>Welcome to My Website</h1>
    <p>This is my first paragraph.</p>

</body>
</html>

Structure Explained

The main tags that form the skeleton of an HTML document:

TagDescription
<!DOCTYPE html>The document type declaration, which tells the browser that this is an HTML5 document.
<html>The root element of an HTML page. The `lang` attribute specifies the language of the document.
<head>Contains meta-information about the document, such as the title and character set.
<title>Specifies a title for the document, which is shown in the browser's title bar or in the page's tab.
<body>Contains the visible page content that is displayed in the browser.