HTML and Web Page Designing - Basic structure of HTML document, text formatting tags, inserting images, creating tables, and building hyperlinks
HyperText Markup Language (HTML) forms the backbone of the World Wide Web. Every web page displayed across web browsers worldwide—from simple blogs to complex dynamic portals—relies on HTML to define its core structure and content. In the CBSE Class 10 Computer Applications curriculum, mastering HTML is a critical foundational step toward understanding web architecture, information presentation, and digital communication.
HTML is not a programming language; it is a markup language. It uses a standardized system of structural markup elements known as tags to instruct web browsers on how text, images, tabular data, and interactive links should be formatted and presented to the user. This study guide provides an exhaustive, practical breakdown of the foundational elements of HTML document creation.
1. In-Depth Conceptual Breakdown
1.1 Fundamentals of HTML Tag Architecture
An HTML document consists of plain text interspersed with tags enclosed in angle brackets (< and >). Tags tell the browser how to interpret the content between them.
HTML tags generally fall into two architectural categories:
-
Container Tags (Paired Tags): These tags require both an opening tag (
<tagname>) and a closing tag (</tagname>). The content to be affected sits between the opening and closing tags.- Syntax:
<tagname>Content goes here...</tagname> - Examples:
<html>...</html>,<body>...</body>,<h1>...</h1>,<p>...</p>.
- Syntax:
-
Empty Tags (Unpaired / Void Tags): These tags do not wrap around any text or content and therefore do not require a closing tag. They insert standalone elements into the page.
- Syntax:
<tagname>or<tagname /> - Examples:
<br>,<hr>,<img>.
- Syntax:
Tag Attributes
Tags can be customized using attributes. An attribute provides additional information or properties for an HTML tag and is always specified inside the opening tag as a name="value" pair.
<element attribute_name="attribute_value">Content</element>
1.2 Basic Structure of an HTML Document
Every standard HTML document follows a strict hierarchical layout. The standard structural layout for an HTML5 document includes the following core tags:
<!DOCTYPE html>
<html>
<head>
<title>Page Title Appears in Browser Tab</title>
</head>
<body>
<!-- Main visible web page content goes here -->
</body>
</html>
Detailed Breakdown of Structural Tags
| Tag | Type | Purpose & Function |
|---|---|---|
<!DOCTYPE html> | Information Directive | Declares the document type and version of HTML (HTML5). It informs the web browser how to render the document correctly. |
<html> | Container Tag | The root element of an HTML document. All other tags and content must be enclosed within <html> and </html>. |
<head> | Container Tag | Contains metadata (information about the page), external resource links, scripts, and the document title. Content inside <head> is not displayed directly in the main browser viewing area. |
<title> | Container Tag | Nested inside <head>. Specifies the text displayed on the web browser’s tab or title bar. It is also used by search engines. |
<body> | Container Tag | Encloses all visible content of the web page, including text, images, headings, tables, forms, and hyperlinks. |
1.3 Text Formatting Tags
HTML provides structural and stylistic tags to format text content effectively.
A. Heading Tags (<h1> to <h6>)
HTML offers six levels of headings. <h1> defines the largest, most significant heading (typically the main title), while <h6> represents the smallest subheading level. Browsers automatically add a line break before and after heading elements.
<h1>Heading Level 1 (Largest)</h1>
<h2>Heading Level 2</h2>
<h3>Heading Level 3</h3>
<h4>Heading Level 4</h4>
<h5>Heading Level 5</h5>
<h6>Heading Level 6 (Smallest)</h6>
B. Paragraph Tag (<p>)
The <p> tag defines a paragraph. Browsers automatically add white space (a blank line margin) before and after any <p> element.
C. Line Break (<br>) and Horizontal Rule (<hr>)
<br>(Empty Tag): Forces a line break at its position without creating a new paragraph block.<hr>(Empty Tag): Inserts a horizontal line across the page, visually separating content sections.- Attributes for
<hr>:color="red",width="80%",size="5",align="center".
- Attributes for
D. Text Styling Tags: Physical vs. Semantic Formatting
| Category | Tag | Description | Example Code | Rendered Output |
|---|---|---|---|---|
| Physical Formatting | <b> | Makes text bold visually. | <b>Bold Text</b> | Bold Text |
<i> | Makes text italic visually. | <i>Italic Text</i> | Italic Text | |
<u> | <u>Underlines</u> text visually. | <u>Underlined Text</u> | <u>Underlined Text</u> | |
| Semantic Formatting | <strong> | Emphasizes importance (rendered bold). | <strong>Important!</strong> | Important! |
<em> | Emphasizes tone (rendered italic). | <em>Take note.</em> | Take note. | |
<mark> | Highlights background of text. | <mark>Highlighted</mark> | Highlighting effect | |
| Mathematical / Scientific | <sub> | Defines subscript text (placed lower). | H<sub>2</sub>O | |
<sup> | Defines superscript text (placed higher). | (a+b)<sup>2</sup> |
Mathematical Formatting Example: To write the algebraic quadratic identity , the HTML code is:
(a + b)<sup>2</sup> = a<sup>2</sup> + 2ab + b<sup>2</sup>
1.4 Inserting Images (<img>)
Images enhance the visual presentation of a web document. The <img> tag is an empty tag used to embed images.
Syntax:
<img src="image_path.jpg" alt="Description of image" width="300" height="200">
Key Attributes of <img>:
src(Source): Specifies the path (URL) of the image file to be displayed. (Mandatory)alt(Alternate Text): Defines descriptive text displayed if the image fails to load (due to slow internet, incorrect path, or screen readers). (Mandatory for accessibility)width&height: Specifies the visual width and height of the image in pixels (px) or percentage (%).title: Specifies advisory text shown as a tooltip when the mouse hovers over the image.
File Path Types:
- Relative Path: Links to an image stored locally relative to the HTML document location (e.g.,
src="images/photo.png"). - Absolute Path: Links to an image using its full Web URL (e.g.,
src="https://www.example.com/images/photo.png").
1.5 Creating Tables (<table>)
Tables present structured grid data organized in horizontal rows and vertical columns.
Essential Table Tags:
<table>: Container tag that defines the table structure.<tr>: Table Row tag. Defines a horizontal row of cells.<th>: Table Header cell. Displays text centered and bold by default.<td>: Table Data cell. Displays standard text aligned to the left by default.<caption>: Specifies the overall title or title caption of the table.
Core Attributes of <table>:
border: Sets the width of the outer border around the table and inner cells (e.g.,border="2").bordercolor: Sets the visual color of table borders (e.g.,bordercolor="blue").bgcolor: Defines the background color of the table or individual cells.width/height: Sets the dimensions of the table in pixels or percentage (width="100%").cellspacing: Specifies the space (in pixels) between adjacent cells.cellpadding: Specifies the distance (in pixels) between the cell wall and the content inside it.
+-----------------------------------------------+
| Cell Outer |
| +-----------------------------------------+ |
| |<------------ Cellpadding ------------->| |
| | | |
| | Cell Content | |
| | | |
| +-----------------------------------------+ |
+-----------------------------------------------+
<---------------- Cellspacing -----------------> (Space to next cell)
Spanning Rows and Columns (colspan and rowspan)
colspan(Column Span): Merges two or more horizontal columns into a single cell. Applied within<td>or<th>.rowspan(Row Span): Merges two or more vertical rows into a single cell. Applied within<td>or<th>.
<!-- Table Spanning Example -->
<table border="1" cellpadding="8">
<tr>
<th colspan="2">Merged Header Across 2 Columns</th>
</tr>
<tr>
<td rowspan="2">Merged Cell Across 2 Rows</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 2</td>
</tr>
</table>
1.6 Building Hyperlinks (<a>)
Hyperlinks allow users to navigate between pages on the web or jump to different sections of the same page. The <a> (Anchor) tag is used to create hyperlinks.
Syntax:
<a href="URL_or_path" target="value">Link Text</a>
Key Attributes of Anchor Tag:
href(Hypertext Reference): Specifies the destination address (URL or file path). Withouthref, the<a>tag will not function as a active link.target: Specifies where to open the linked document:target="_blank": Opens the linked document in a new tab or window.target="_self": Opens the document in the same tab (Default behavior).
title: Adds a pop-up description text when hovering over the hyperlink.
Types of Links:
-
External Hyperlink: Points to a page outside the current website domain.
<a href="https://www.ncert.nic.in" target="_blank">Visit Official NCERT Website</a> -
Internal/Local Hyperlink: Links to another HTML document located on the same local server or computer.
<a href="contact.html">Contact Us</a> -
Image Hyperlink: Uses an image instead of text as the clickable link.
<a href="home.html"> <img src="home_icon.png" alt="Home" width="50" height="50"> </a>
2. Real-World Applications & Conceptual Analogies
Analogy 1: Building Construction vs. Web Page Development
Think of HTML as the structural skeleton of a building.
- The basic HTML setup (
<html>,<head>,<body>) is like setting up the foundation, outer structural frame, and designated rooms. - Paragraphs (
<p>), headings (<h1>), and tables (<table>) represent structural fixtures like walls, signs, and filing cabinets. - CSS (Cascading Style Sheets) represents the interior decoration (paint, wallpapers, lighting), while JavaScript represents electrical devices and dynamic automation (switches, automated doors).
Application 2: Digital School Report Card Portal
Schools publish student marks on digital web portals using HTML:
- Structural tags organize the layout.
<table border="1">displays subject-wise marks cleanly with columns for Subject, Maximum Marks, and Marks Obtained.- Attributes like
colspanallow adding a summary footer row ("Overall Distinction Grade"), while<a href="download_pdf.html">provides a direct link to download the formal report.
Application 3: E-Commerce Product Listing Page
When visiting an online shopping portal:
<img src="laptop.jpg" alt="Gaming Laptop">presents the product image clearly.<h2>displays the product title, while<sub>and<sup>format discounted price calculations and mathematical dimensions ().- An anchor link
<a href="cart.html">wrapped around an image button acts as the clickable "Add to Cart" action element.
3. Step-by-Step Solved Coding Examples
Solved Example 1: Creating a Formatted School Notice Web Page
Task: Write complete HTML code to display a school notice board page containing a main heading level 1, a horizontal line separator, a detailed paragraph with bold and underlined text, and a chemical reaction formula .
Solution Code:
<!DOCTYPE html>
<html>
<head>
<title>School Science Exhibition Notice</title>
</head>
<body>
<h1 align="center">GREENWOOD PUBLIC SCHOOL</h1>
<h3 align="center">Annual Science Exhibition 2025</h3>
<hr color="green" size="3" width="90%">
<p>
This is to inform all students of <b>Class 10</b> that the Annual
<u>Science Exhibition</u> will take place on <i>15th November 2025</i> in the main auditorium.
</p>
<p>
<b>Featured Experiment Formula:</b><br>
Water Synthesis: 2H<sub>2</sub> + O<sub>2</sub> → 2H<sub>2</sub>O
</p>
<p>
For registrations, contact your respective Class Teacher.
</p>
</body>
</html>
Solved Example 2: HTML Page with Formatted Data Table
Task: Write an HTML document to generate the following table layout containing student examination scores, including colspan for total marks:
| Roll No | Student Name | Science | Mathematics |
|---|---|---|---|
| 101 | Rahul Sharma | 88 | 95 |
| 102 | Priya Verma | 92 | 90 |
| Total Passed Students | 2 |
Solution Code:
<!DOCTYPE html>
<html>
<head>
<title>Student Scoreboard</title>
</head>
<body>
<h2>Class 10 Academic Performance Summary</h2>
<table border="2" cellpadding="8" cellspacing="0" width="80%">
<caption><b>Mid-Term Results 2024-25</b></caption>
<tr bgcolor="#d3d3d3">
<th>Roll No</th>
<th>Student Name</th>
<th>Science</th>
<th>Mathematics</th>
</tr>
<tr>
<td align="center">101</td>
<td>Rahul Sharma</td>
<td align="center">88</td>
<td align="center">95</td>
</tr>
<tr>
<td align="center">102</td>
<td>Priya Verma</td>
<td align="center">92</td>
<td align="center">90</td>
</tr>
<tr>
<th colspan="2">Total Passed Students</th>
<th colspan="2">2</th>
</tr>
</table>
</body>
</html>
Solved Example 3: Creating Interlinked Pages with Image Links
Task: Create an HTML snippet for a photo gallery page where clicking a thumbnail image opens a full resolution external link in a new tab. Also, include an internal link to navigate back to index.html.
Solution Code:
<!DOCTYPE html>
<html>
<head>
<title>Photo Gallery</title>
</head>
<body>
<h1>School Campus Gallery</h1>
<p>Click on the photo preview below to view full-sized image:</p>
<!-- Image embedded inside Anchor tag -->
<a href="https://example.com/images/campus_large.jpg" target="_blank">
<img src="campus_thumb.jpg" alt="School Campus Thumbnail" width="200" height="150" border="2">
</a>
<br><br>
<hr>
<!-- Internal Hyperlink -->
<a href="index.html">Return to Home Page</a>
</body>
</html>
4. Common Student Mistakes to Avoid
1. Confusing cellpadding and cellspacing
- Mistake: Reversing the function of cell space attributes in tables.
- Correction:
cellpadding: Space inside the cell (between text content and inner border).cellspacing: Space outside the cell (between two adjacent table cells).
2. Nesting HTML Tags Incorrectly
- Mistake: Closing tags in an incorrect sequence (e.g.,
<b><i>Formatted Text</b></i>). - Correction: Tags must be closed in Last-In, First-Out (LIFO) order. The last tag opened must be closed first:
<b><i>Formatted Text</i></b>.
3. Inserting Incorrect Path Syntax in src or href
- Mistake: Writing file extensions incorrectly or adding invalid disk file locations (e.g.,
src="C:\Users\Admin\Desktop\photo.png"), which breaks when evaluated by an external browser or uploaded to a server. - Correction: Always use relative file paths for locally stored project files (e.g.,
src="images/photo.png") and verify exact case sensitivity and file extensions (.jpgvs.jpeg).
4. Using Closing Slashes on Empty/Void Tags
- Mistake: Writing paired closing tags for empty tags such as
<br></br>or<img></img>. - Correction: Tags like
<br>,<hr>, and<img>are void elements; they do not wrap text and should never have standalone closing tags.
5. Practice Questions for Self-Assessment
Question 1 (Medium Difficulty)
Write an HTML script to construct a web page titled "Library Portal" with:
- Main heading: "Welcome to Central Library".
- A bullet list background color set to light yellow (
#FFFFE0). - Formatted text containing chemical and mathematical identities:
- Acid:
- Theorem:
- An external hyperlink to
https://www.ndl.gov.in(National Digital Library) that opens in a new tab.
Question 2 (High Difficulty - Table Construction)
Write HTML code to generate the following weekly timetable grid:
| Day | Period 1 | Period 2 | Period 3 |
|---|---|---|---|
| Monday | Math | Science | English |
| Tuesday | <td colspan="2">Computer Practical (2 Periods)</td> | Social Studies | |
| Wednesday | Science | Math | Sports |
Solutions to Practice Questions
Solution to Question 1:
<!DOCTYPE html>
<html>
<head>
<title>Library Portal</title>
</head>
<body bgcolor="#FFFFE0">
<h1 align="center">Welcome to Central Library</h1>
<hr color="black" size="2">
<h3>Important Scientific Formulas for Reference</h3>
<p>
1. Sulphuric Acid Formula: H<sub>2</sub>SO<sub>4</sub><br>
2. Algebraic Identity: (x+y)<sup>2</sup> = x<sup>2</sup> + 2xy + y<sup>2</sup>
</p>
<h3>Digital Resources</h3>
<p>
Access online books:
<a href="https://www.ndl.gov.in" target="_blank">Visit National Digital Library</a>
</p>
</body>
</html>
Solution to Question 2:
<!DOCTYPE html>
<html>
<head>
<title>Class Timetable</title>
</head>
<body>
<h2>Weekly Class Timetable</h2>
<table border="2" cellpadding="10" cellspacing="0">
<tr bgcolor="#cccccc">
<th>Day</th>
<th>Period 1</th>
<th>Period 2</th>
<th>Period 3</th>
</tr>
<tr>
<th>Monday</th>
<td>Math</td>
<td>Science</td>
<td>English</td>
</tr>
<tr>
<th>Tuesday</th>
<td colspan="2" align="center"><b>Computer Practical</b></td>
<td>Social Studies</td>
</tr>
<tr>
<th>Wednesday</th>
<td>Science</td>
<td>Math</td>
<td>Sports</td>
</tr>
</table>
</body>
</html>
6. Exam Revision & Frequently Asked Questions (FAQs)
Q1. What is the fundamental difference between Container Tags and Empty Tags in HTML? Give two examples of each.
Answer:
- Container Tags: Require both an opening tag (
<tag>) and a closing tag (</tag>) to wrap content.- Examples:
<html>...</html>,<p>...</p>,<h1>...</h1>.
- Examples:
- Empty Tags: Do not enclose content and do not require a closing tag. They insert structural elements directly.
- Examples:
<br>,<hr>,<img>.
- Examples:
Q2. Differentiate between <b> tag and <strong> tag, as well as <i> tag and <em> tag.
Answer: While both sets render visually identical outputs in standard browsers:
<b>vs<strong>:<b>is a physical tag that simply makes text visually bold without adding extra meaning.<strong>is a semantic tag that marks text as structurally important for screen readers and search engines.<i>vs<em>:<i>changes text visually to italics.<em>is a semantic tag that places stylistic emphasis on the spoken tone of the text.
Q3. How do rowspan and colspan attributes differ when designing HTML tables?
Answer:
colspan(Column Span): Merges multiple horizontally adjacent cells into a single unified cell across columns.rowspan(Row Span): Merges multiple vertically adjacent cells into a single unified cell across rows.
Q4. What happens if the alt attribute is omitted from an <img> tag? Why is it considered best practice to include it?
Answer:
If the alt attribute is omitted, the browser displays a broken image icon or blank space without explaining the content if the image fails to load. Including alt is critical because:
- It provides accessible text descriptions for visually impaired users relying on screen readers.
- It displays alternative context if network failure prevents the visual image from loading.
- It allows search engines to index image context accurately.