HTML Tags Overview
1. Basic Structure Tags
These tags form the essential structure of an HTML document:
- <!DOCTYPE html>: Defines the document type as HTML5.
- <html>: Wraps the entire HTML document.
- <head>: Contains meta-information like the title and links to resources.
- <title>: Sets the page title shown on the browser tab.
- <body>: Wraps all visible content on the webpage.
2. Text Formatting Tags
Use these tags to format text:
- <h1> ... <h6>: Header tags, from largest (
<h1>
) to smallest (<h6>
).
- <p>: Defines a paragraph of text.
- <b> / <strong>: Makes text bold.
<strong>
adds emphasis.
- <i> / <em>: Italicizes text.
<em>
adds emphasis.
- <br>: Inserts a line break.
- <hr>: Adds a horizontal line.
3. Links and Media Tags
Use these tags to add links and media:
- <a href="URL">: Creates a hyperlink.
- <img src="URL" alt="text">: Displays an image with alt text for accessibility.
- <audio>: Embeds an audio file.
- <video>: Embeds a video file.
4. List Tags
To create lists:
- <ul>: Creates an unordered list (bullets).
- <ol>: Creates an ordered list (numbers).
- <li>: List item, used inside
<ul>
or <ol>
.
5. Table Tags
Use these tags to create tables:
- <table>: Creates a table.
- <tr>: Defines a row.
- <th>: Table header cell.
- <td>: Table data cell.
6. Form Tags
To create forms for user input:
- <form>: Wraps form elements.
- <input>: Input field with attributes like
type
, name
, and placeholder
.
- <textarea>: Multi-line text input.
- <button>: Button for form submission.
7. Div and Span
Grouping content:
- <div>: Block-level container for grouping content.
- <span>: Inline container for styling inline text or grouping elements.
Additional Notes
Closing and Self-Closing Tags
Most tags require both opening and closing tags (e.g., <p>content</p>
), while some are self-closing (e.g., <img>
, <br>
, <hr>
).
Attributes
Attributes provide additional information about elements:
- id: Unique identifier for an element.
- class: Assigns a class for styling.
- style: Inline CSS styles.
Nesting and Hierarchy
HTML allows nesting of tags within each other. Proper nesting ensures correct document structure and styling.
HTML Documentation
This document provides a comprehensive overview of HTML tags and elements, from structure to styling, enabling readers to understand and implement HTML effectively in their web development projects.