HTML TAGS
Overview
HTML tags are the building blocks of web pages, used to structure and format
content. They are enclosed in angle brackets (< >) and typically come in pairs: an
opening tag (e.g., <p>) and a closing tag (e.g., </p>). Some tags, like <img> and
<br>, are self-closing and do not require a closing tag.
Commonly Used HTML Tags
Structural Tags
• <!DOCTYPE html>: Declares the document type and version of HTML.
• <html>: Represents the root of an HTML document.
• <head>: Contains metadata, links to stylesheets, and scripts.
• <body>: Encloses the main content of the document.
Text Formatting Tags
• <h1> to <h6>: Define headings, with <h1> being the largest and <h6> the
smallest.
• <p>: Defines a paragraph.
• <b>: Makes text bold.
• <i>: Italicizes text.
• <u>: Underlines text.
• <strong>: Indicates important text (bold by default).
• <em>: Emphasizes text (italic by default).
Media and Interactive Tags
• <img>: Embeds an image. Attributes like src and alt are used for the source
and alternative text.
• <a>: Creates hyperlinks. The href attribute specifies the link destination.
• <video>: Embeds video content.
• <audio>: Embeds audio content.
• <button>: Creates a clickable button.
List Tags
• <ul>: Defines an unordered list.
• <ol>: Defines an ordered list.
• <li>: Represents a list item.
Table Tags
• <table>: Creates a table.
• <tr>: Defines a table row.
• <td>: Defines a table cell.
• <th>: Defines a table header cell.
Form Tags
• <form>: Creates a form for user input.
• <input>: Defines an input field.
• <label>: Labels an input element.
• <textarea>: Creates a multi-line text input field.
• <button>: Submits the form or performs an action.
Semantic Tags
• <header>: Represents introductory content or navigation links.
• <footer>: Represents footer content.
• <article>: Defines self-contained content like articles or blog posts.
• <section>: Groups related content.
• <nav>: Defines navigation links.
Miscellaneous Tags
• <div>: Defines a division or section in a document (used for grouping
content).
• <span>: Used for inline grouping of elements.
• <script>: Embeds or references JavaScript code.
• <style>: Embeds CSS styles.
Key Considerations
HTML5 introduced several new semantic tags like <article>, <section>, and
<footer> to improve content structure. Deprecated tags like <font> and <center>
should be avoided in favor of CSS for styling. Always use proper nesting and
closing of tags to ensure valid and accessible HTML.