HTML tags are the building blocks of an HTML document. They define the structure and content of web pages. The tags can be broadly categorized based on their function and the type of content they represent. Here’s an overview of the different types of HTML tags:
1. Structural Tags
These tags define the structure of an HTML document.
<html>
: The root element that wraps the entire HTML document.<head>
: Contains metadata, links to external resources, and other information about the document (e.g., title, style, script).<body>
: Contains the visible content of the web page.<header>
: Represents introductory content or a navigation section.<footer>
: Represents footer content, usually for legal or contact information.<section>
: Defines a section in a document, such as a group of related content.<article>
: Represents independent, self-contained content like a blog post or news article.<nav>
: Defines a navigation section for links to other parts of the site.<main>
: Represents the dominant content of the<body>
.
2. Text Content Tags
These tags are used to define and format text content.
<h1>
,<h2>
,<h3>
,<h4>
,<h5>
,<h6>
: Headings, where<h1>
is the highest level and<h6>
is the lowest.<p>
: Paragraphs of text.<a>
: Hyperlinks to other web pages or resources.<b>
: Bold text.<i>
: Italic text.<strong>
: Text with strong emphasis (typically rendered in bold).<em>
: Text with emphasized meaning (typically rendered in italics).<u>
: Underlined text.<br>
: Line break, used to break the content into a new line.<span>
: A generic container for inline content.<blockquote>
: A block-level quote, used for quoting content from another source.<code>
: Defines inline code.<pre>
: Preformatted text, preserves whitespace and line breaks.<mark>
: Highlights or marks text.<small>
: Renders text in smaller font size.
3. List Tags
Used to define different types of lists.
<ul>
: Unordered list (bulleted list).<ol>
: Ordered list (numbered list).<li>
: List item, used inside both<ul>
and<ol>
.
4. Table Tags
Used to define tables and their content.
<table>
: Defines a table.<tr>
: Table row.<th>
: Table header cell.<td>
: Table data cell.<caption>
: Provides a title for a table.<thead>
: Groups the header content in a table.<tbody>
: Groups the body content in a table.<tfoot>
: Groups the footer content in a table.
5. Form Tags
These tags define interactive forms and user input elements.
<form>
: Defines an HTML form for user input.<input>
: Defines an input field (e.g., text, checkbox, radio button).<textarea>
: Defines a multi-line text input.<button>
: Defines a clickable button.<select>
: Defines a dropdown list.<option>
: Defines options inside a<select>
dropdown.<label>
: Defines a label for an input element.<fieldset>
: Groups related form elements.<legend>
: Provides a caption for a<fieldset>
.
6. Media Tags
These tags are used to embed multimedia content like images, videos, and audio.
<img>
: Defines an image.<audio>
: Embeds audio content (e.g., music or sound files).<video>
: Embeds video content.<source>
: Defines multiple media sources for<audio>
or<video>
.<iframe>
: Embeds another document (such as another webpage) within the current page.<embed>
: Embeds external content like multimedia or plugins.<object>
: Embeds an object such as a PDF, Flash, or other media.
7. Semantic Tags
These tags provide meaning to the content, making it more accessible and search-engine friendly.
<article>
: Defines a self-contained content block (e.g., a blog post).<section>
: Represents a generic section of content.<aside>
: Defines content that is tangentially related to the main content (e.g., sidebars).<header>
: Defines introductory content or navigation links.<footer>
: Defines footer content.<figure>
: Used to group media content like images, illustrations, or videos, along with their captions.<figcaption>
: Defines a caption for<figure>
content.<time>
: Defines a specific time or date.<details>
: Defines additional details that can be toggled by the user.<summary>
: Defines a summary or heading for the<details>
element.
8. Meta Tags
Meta tags provide metadata about the HTML document.
<meta>
: Defines metadata such as character encoding, viewport settings, or document description.<title>
: Sets the title of the web page, which appears in the browser tab.<link>
: Defines relationships between the document and external resources (e.g., linking a stylesheet).<style>
: Defines CSS styles directly in the HTML document.<script>
: Defines JavaScript code or links to external scripts.
9. Link and Anchor Tags
Used to create links to other pages or resources.
<a>
: Defines a hyperlink to another webpage or resource.<link>
: Specifies relationships between the document and external resources (commonly used to link stylesheets).
10. Miscellaneous Tags
Other utility tags that don’t fit neatly into the above categories.
<div>
: A generic container element, often used for layout and grouping content.<span>
: A generic inline container, used for styling or grouping inline content.
Summary Table:
Type | Example Tags |
---|---|
Structural | <html> , <head> , <body> , <header> , <footer> |
Text Content | <h1> , <p> , <a> , <strong> , <em> |
Lists | <ul> , <ol> , <li> |
Tables | <table> , <tr> , <td> , <th> |
Forms | <form> , <input> , <textarea> , <button> |
Media | <img> , <audio> , <video> , <iframe> |
Semantic | <article> , <section> , <nav> , <aside> |
Meta | <meta> , <title> , <link> , <style> |
Links | <a> , <link> |
Miscellaneous | <div> , <span> , <br> , <code> |
These categories help organize and define the functionality of HTML tags, and knowing which tags to use in each context is crucial for building structured, maintainable, and accessible web pages.