1. Understanding Web Pages
1.1 What is HTML?
HTML, which stands for HyperText Markup Language, is the standard language used to create and structure web pages. Unlike programming languages, HTML is a markup language composed of various tags that define the structure and content of a webpage.
The term "HyperText" has two key interpretations:
- It supports multimedia content including images, audio, animations, and video—going beyond plain text capabilities.
- It enables hyperlinks that connect to files hosted on servers worldwide.
1.2 How Web Pages are Created
A webpage consists of various elements that are defined using HTML tags. Browsers interpret these tags and render the content for users to view.
2. Popular Web Browsers
Browsers serve as the platform for displaying and running web content. The major browsers include Chrome, Firefox, Safari, Edge, and Opera.
Browser Rendering Engines
Browser engines (rendering engines) are responsible for parsing webpage content, organizing information, calculating layout, and displaying the page.
3. Web Standards
Web standards are established by the W3C (World Wide Web Consortium) and other organizations to ensure consistency and accessibility across the web.
3.1 Components of Web Standards
Web standards comprise three main aspects:
3.2 Best Practice Approach
The ideal methodology separates concerns: place structure in HTML files, presentation in CSS files, and behavior in JavaScript files.
4. HTML Tag Syntax
4.1 Basic Syntax Rules
HTML tags are enclosed in angle brackets. Most tags come in pairs (opening and closing tags), while some are self-closing. Key points:
- Tags are surrounded by angle brackets, like
<html> - Paired tags have opening and closing versions, such as
<div>and</div> - Self-closing tags like
<br/>don't require a closing tag
4.2 Tag Relationships
Tags can be nested in two ways: parent-child (containing) relationships and sibling (parallel) relationships.
4.3 Document Declaration
This declaration tells the browser to render the page using HTML5. It must be placed before the <html> tag and is not itself an HTML tag—just a document type declaration.
4.4 Language Declaration
The lang attribute specifies the document's language:
lang="en"for Englishlang="zh-CN"for Simplified Chinese
4.5 Character Encoding
<meta charset="UTF-8">
This declaration ensures proper character display across different languages.
5. Semantic HTML Elements
Understanding semantic meaning is crucial when learning HTML—each tag carries specific purpose and conveys its function to both browsers and developers.
5.1 Heading Tags <h1> through <h6>
Headings provide document structure and hierarchy. HTML offers six heading levels, with <h1> being the most important:
- Text becomes bold and progressively smaller from h1 to h6
- Each heading occupies its own line
5.2 Paragraph and Line Break Tags
Text flows left-to-right within paragraphs until the viewport edge. Use <br/> for forced line breaks.
5.3 Text Formatting Tags
The semantic versions (<strong>, <em>, <del>, <ins>) are preferred as they convey stronger meaning.
5.4 Container Tags: <div> and <span>
<div>Header Section</div>
<span>Current Price</span>
<div> (division) serves as a block-level container, while <span> is an inline container:
<div>: Block-level, occupies full width, typically used for major layout sections<span>: Inline-level, only takes necessary width, used for small content groupings
6. Images and Paths
6.1 Image Tag Syntax
<img src="image.jpg" alt="Description" />
The src attribute is required and specifies the image path.
6.2 Image Tag Attributes
Attributes follow key-value syntax and can be listed in any order.
6.3 Path Types
Relative Paths: Defined relative to the current file location.
Absolute Paths: Full paths starting from a drive letter or domain.
7. Hyperlinks
7.1 Anchor Tag Syntax
<a href="url" target="_blank">Link Text</a>
7.2 Link Categories
-
External Links: Point to other websites
-
Internal Links: Navigate between pages within the same site
-
Empty Links: Use
href="#"for placeholders -
Download Links: Link to .exe or .zip files
-
Element Links: Any element (image, audio, video) can be made clickable
-
Anchor Links: Navigate to specific page sections ```
Go to Section 2
8. Comments and Special Characters
Comments help document code without displaying in the browser:
<!-- This is a comment -->
Special characters require entity codes:
9. Tables
9.1 Table Purpose
Tables excel at displaying structured data in organized rows and columns, making complex information easy to scan and understand.
9.2 Basic Table Structure
<table>
<tr>
<td>Data Cell</td>
</tr>
</table>
Key elements:
<table>: Defines the table container<tr>: Creates table rows<td>: Contains cell data (table data)
9.3 Table Headers
<table>
<tr>
<th>Header Text</th>
</tr>
</table>
<th> creates header cells that are bold and centered by default.
9.4 Table Attributes
9.5 Table Structure Tags
<table>
<thead>
<tr>
<th>Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data</td>
</tr>
</tbody>
</table>
Use <thead> for header rows and <tbody> for data rows to improve semantic structure.
9.6 Merging Cells
Cells can span multiple rows or columns:
rowspan: Merges verticallycolspan: Merges horizontally
Procedure for merging:
- Determine if row-span or column-span is needed
- Identify the target cell (topmost for row-span, leftmost for column-span)
- Add the colspan or rowspan attribute with the number of cells to span
- Remove the cells that were covered by the merge
10. List Tags
Lists organize content in structured, readable arrangements. Three types are available:
10.1 Unordered Lists
<ul>
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li>
</ul>
Guidelines:
- Only
<li>elements can nest directly inside<ul> <li>containers can hold any other elements- Default bullet styling is typically overridden with CSS
10.2 Ordered Lists
<ol>
<li>Step One</li>
<li>Step Two</li>
</ol>
Same nesting rules apply as unordered lists.
10.3 Definition Lists
<dl>
<dt>Term</dt>
<dd>Definition of the term</dd>
<dd>Additional description</dd>
</dl>
Guidelines:
<dl>contains only<dt>and<dd>elements- Each term can have multiple definitions
11. Form Elements
11.1 Form Structure
A complete form consists of three components: form container, form controls, and labels.
11.2 Form Tag
<form action="submit.php" method="POST" name="survey">
Form controls go here
</form>
11.3 Input Element
<input type="text" name="username" value="Default" />
Key attributes:
name: Variable name sent to servervalue: Pre-filled contentchecked: Default selection for checkboxes/radio buttonsmaxlength: Maximum character limit
11.4 Label Element
<label for="email">Email Address</label>
<input type="email" id="email" name="email" />
The for attribute connects the label to the input's id, improving accessibility and allowing click-to-focus functionality.
11.5 Select Dropdown
<select name="country">
<option value="us">United States</option>
<option value="uk" selected>United Kingdom</option>
<option value="ca">Canada</option>
</select>
Guidelines:
- At least one
<option>is required - Use
selectedattribute too set the default selection
11.6 Textarea Element
<textarea name="comments" rows="4" cols="30">
Enter your feedback here
</textarea>
Creates a multi-line text input. Width and height are typically controlled via CSS rather than attributes.