Structure of HTML

 

Structure of an HTML Document

Every HTML page follows a fixed basic structure that tells the browser how to read and display the webpage.

Basic HTML Document Structure

<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <!-- Visible content goes here --> </body> </html>

Explanation of Each Part

1. <!DOCTYPE html>

  • Declares the document type

  • Tells the browser this is an HTML5 document

  • Must be the first line in the file

📌 Without it, browsers may behave unpredictably.


2. <html> Tag

  • Root (parent) element of the HTML page

  • All other tags are written inside it

<html> ... </html>

3. <head> Section

Contains information about the webpage, not visible to users.

Common elements inside <head>:

  • <title> – page title

  • <meta> – character set, viewport, SEO

  • <link> – CSS files

  • <style> – internal CSS

  • <script> – JavaScript (sometimes)

Example:

<head> <title>My Website</title> <meta charset="UTF-8"> </head>

4. <title> Tag

  • Sets the browser tab title

  • Used by search engines

  • Must be inside <head>


5. <body> Section

Contains all visible content of the webpage.

Examples:

  • Headings

  • Paragraphs

  • Images

  • Links

  • Forms

  • Tables

<body> <h1>Hello</h1> <p>This is my webpage.</p> </body>

Diagram Representation

<!DOCTYPE html> | <html> | <head> → Metadata (not visible) | <body> → Visible webpage content

Complete Example

<!DOCTYPE html> <html> <head> <title>HTML Structure</title> <meta charset="UTF-8"> </head> <body> <h1>HTML Document</h1> <p>This shows the basic structure of an HTML page.</p> </body> </html>

Important Points (Exam / Interview)

<!DOCTYPE html> defines HTML version
<html> is the root element
<head> contains metadata
<body> contains visible content
<title> appears on browser tab

Comments

Popular posts from this blog

What is HTML?