Basic Structure of an HTML Document
An HTML document is made up of different tags that define how the web page looks and
behaves.
1. DOCTYPE Declaration
• Declares the type and version of HTML.
• Tells the browser how to render the page.
• Example:
o HTML5: <!DOCTYPE html>
o HTML 4.01 and XHTML have longer declarations.
• Not case sensitive (<!DOCTYPE html> = <!Doctype Html>).
2. Main Parts of HTML Document
Every HTML page has two main sections:
1. Head Section
o Contains meta information, styles, and scripts.
o Does not display on the browser screen.
o Common tags inside <head>:
▪ <title> → Defines page title (shown on browser tab).
▪ <style> → CSS styles.
▪ <script> → JavaScript codes.
▪ <link> → Connects external CSS or files.
▪ <base> → Base URL of the page.
2. Body Section
o Displays actual content on the screen.
o Can contain text, images, links, tables, forms, etc.
o Example:
o <body bgcolor="yellow">
o <h1>Welcome</h1>
o </body>
3. HTML Constructs
HTML has three basic constructs:
1. Elements (Tags)
o Written inside angle brackets < >.
o Most come in pairs: <p> ... </p>.
o Example: <b>Welcome</b> → Bold text.
2. Attributes
o Provide extra information about elements.
o Written as name="value" inside the start tag.
o Example: <font color="red" size="5">Text</font>.
3. Entities
o Special codes to display reserved characters.
o Example:
▪ < → <
▪ > → >
▪ & → &
▪ Space →
4. Important Document Tags
• <html> → Root of HTML document.
• <head> → Contains title, CSS, JS.
• <title> → Page title.
• <body> → All visible content.
5. Formatting Tags
Used to change the look of text.
Tag Function Example
<b> Bold text <b>Hello</b>
<i> Italic text <i>Hello</i>
<u> Underlined text <u>Hello</u>
<big> Bigger text <big>Hello</big>
Tag Function Example
<small> Smaller text <small>Hello</small>
<s> or <strike> Strike-through <s>Hello</s>
<sub> Subscript H<sub>2</sub>O
<sup> Superscript x<sup>2</sup>
<font> Change font, size, color <font color="blue">Hi</font>
<br> Line break Hello<br>World
<center> Center text <center>Hello</center>
<em> Emphasized text <em>Hello</em>
<mark> Highlighted text <mark>Hello</mark>
<del> Deleted text <del>Hello</del>
<ins> Inserted text <ins>Hello</ins>
<hr> Horizontal line <hr color="red">
<h1>…<h6> Headings <h1>Main Title</h1>
<p> Paragraph <p align="center">Text</p>
<pre> Preformatted text <pre>line 1\nline 2</pre>
<span> Inline styling <span style="color:red;">Text</span>
6. Example Program
<!DOCTYPE html>
<html>
<head>
<title>My First Page</title>
</head>
<body bgcolor="yellow">
<center>
<h1>Welcome to HTML 5</h1>
<p>This is <b>bold</b> and <i>italic</i> text.</p>
<hr color="blue">
</center>
</body>
</html>