Document Structure
These tags define the overall structure of an HTML document.
| Tag | Description | Key Attributes |
|---|---|---|
| <!DOCTYPE html> | Declares this as an HTML5 document. Must be the first line. | β |
| <html> | Root element. All other elements go inside it. | lang (e.g., "en") |
| <head> | Contains metadata: title, charset, viewport, links, scripts. | β |
| <body> | Contains all visible content of the page. | β |
| <title> | Page title shown in browser tab. Critical for SEO. | β |
| <meta> | Metadata: charset, viewport, description, keywords, author. | charset, name, content, http-equiv |
| <link> | Links external resources: CSS, fonts, favicons. | rel, href, type |
| <script> | Embed or link JavaScript code. | src, type, defer, async |
| <style> | Internal CSS styles. Place in <head>. | type, media |
Text & Content
Tags for organizing and marking up text content.
| Tag | Description | Key Attributes |
|---|---|---|
| <h1>...<h6> | Headings. <h1> is largest, <h6> is smallest. Use one <h1> per page. |
β |
| <p> | Paragraph. Block-level element with bottom margin. | β |
| <span> | Inline container. No inherent styling. Use with class or id. | β |
| <div> | Block container. Generic division for grouping content. | β |
| <br> | Line break. Self-closing. Avoid for spacingβuse CSS instead. | β |
| <hr> | Horizontal rule (thematic break). Self-closing. | β |
| <blockquote> | Long quotation. Block-level with indentation. | cite (URL to source) |
| <pre> | Preformatted text. Preserves spaces and line breaks. Use for code. | β |
| <code> | Inline code. Use inside <pre> for blocks. |
β |
Formatting & Emphasis
Tags for semantic emphasis and text styling.
| Tag | Description | Key Attributes |
|---|---|---|
| <strong> | Strong importance. Default: bold. Semantic: screenreaders emphasize. | β |
| <b> | Bold text. No semantic importance. Use <strong> instead. |
β |
| <em> | Emphasis. Default: italic. Semantic: screenreaders emphasize. | β |
| <i> | Italic text. No semantic emphasis. Use <em> instead. |
β |
| <mark> | Highlighted/marked text. Default: yellow background. | β |
| <small> | Small text. Legal text, disclaimers, fine print. | β |
| <del> | Deleted text. Default: strikethrough. Semantic: content removed. | datetime, cite |
| <ins> | Inserted text. Default: underline. Semantic: content added. | datetime, cite |
| <sub> | Subscript. Use for: H2O, footnotes. | β |
| <sup> | Superscript. Use for: E=mc2, citations. | β |
Links & Media
Tags for hyperlinks, images, audio, video.
| Tag | Description | Key Attributes |
|---|---|---|
| <a> | Hyperlink. Navigate to URLs or page sections. | href, target, title, rel |
| <img> | Image. Self-closing. Always include alt text for accessibility. | src, alt, width, height, title |
| <picture> | Responsive images. Contains <source> and <img>. |
β |
| <source> | Specify media sources for <picture>, <audio>, <video>. |
src, srcset, media, type |
| <video> | Embed video. Contains <source> tags and fallback content. |
src, controls, width, height, poster, autoplay, loop |
| <audio> | Embed audio. Contains <source> tags and fallback content. |
src, controls, autoplay, loop |
| <figure> | Self-contained illustration, diagram, photo. Often with caption. | β |
| <figcaption> | Caption for a <figure>. Must be first/last child. |
β |
| <map> & <area> | Client-side image map with clickable regions. | name, shape, coords, href |
Lists
Tags for ordered, unordered, and description lists.
| Tag | Description | Key Attributes |
|---|---|---|
| <ul> | Unordered list (bulleted). Contains <li> items. |
type (disc, circle, square) |
| <ol> | Ordered list (numbered). Contains <li> items. |
type (1, a, A, i, I), start |
| <li> | List item. Child of <ul> or <ol>. |
value (for <ol>) |
| <dl> | Description list. Contains <dt> (term) and <dd> (definition). |
β |
| <dt> | Definition term. Child of <dl>. |
β |
| <dd> | Definition description. Child of <dl>. |
β |
Tables
Tags for tabular data. Not for layoutβuse CSS Grid/Flexbox instead.
| Tag | Description | Key Attributes |
|---|---|---|
| <table> | Table container. Contains <tr>, <th>, <td>. |
border, cellpadding, cellspacing (deprecatedβuse CSS) |
| <thead> | Table header group. Contains header rows. One per table. | β |
| <tbody> | Table body group. Contains data rows. One per table. | β |
| <tfoot> | Table footer group. Contains footer rows. One per table. | β |
| <tr> | Table row. Contains <th> or <td> cells. |
β |
| <th> | Table header cell. Bold, centered by default. Use in <thead>. |
scope (row, col, rowgroup, colgroup) |
| <td> | Table data cell. Regular cell content. | colspan, rowspan |
| <caption> | Table title/caption. First child of <table>. |
β |
| <colgroup> & <col> | Define column groups for styling. <col> is self-closing. |
span, style |
Forms
Tags for building interactive forms and collecting user input.
| Tag | Description | Key Attributes |
|---|---|---|
| <form> | Form container. Contains input fields, buttons, labels. | action, method (GET, POST), enctype |
| <label> | Associates text with form control. Click label to focus input. Use for accessibility. | for (matches input id) |
| <input> | Single-line input field. Self-closing. Type depends on type attribute. |
type, name, value, placeholder, required, disabled, readonly |
| <textarea> | Multi-line text input. For longer text. Has closing tag. | name, rows, cols, placeholder, required, readonly |
| <select> | Dropdown menu. Contains <option> or <optgroup>. |
name, multiple, size, required |
| <option> | Menu option inside <select>. |
value, selected, disabled |
| <optgroup> | Group options in a <select> menu. |
label, disabled |
| <button> | Clickable button. Type: submit, reset, button. More flexible than <input type="button">. |
type, name, value, disabled, form |
| <fieldset> | Group related form fields. Draws border. Use with <legend>. |
disabled, name, form |
| <legend> | Caption for a <fieldset>. First child of fieldset. |
β |
| <datalist> | Suggestions for an input field. Contains <option> elements. |
id |
| <output> | Displays calculation results (JS computed values). | for, name, form |
text, email, password, number, range, date, time, checkbox, radio, file, submit, reset, button, search, tel, url, color, and more.
Semantic HTML
Tags with meaning. Help screenreaders, search engines, and developers understand page structure.
| Tag | Description | Key Attributes |
|---|---|---|
| <header> | Top of page or section. Contains logo, nav, title. Usually has <nav>. |
β |
| <nav> | Navigation links. Major navigation section. Not every link needs <nav>. |
β |
| <main> | Main content area. One per page. Excludes header, nav, footer, sidebar. | β |
| <article> | Self-contained content: blog post, news article, forum post, product review. | β |
| <section> | Thematic grouping. Each section has a heading. Not just for styling. | β |
| <aside> | Sidebar. Tangentially related to main content. Not critical. | β |
| <footer> | Bottom of page or section. Copyright, links, contact, meta. | β |
| <address> | Contact information. Email, phone, physical address. | β |
| <time> | Machine-readable date/time. Use with datetime attribute. |
datetime |
HTML5 Input Types
Modern input types provide built-in validation and mobile keyboards.
| Type | Purpose | Browser Support |
|---|---|---|
| text | Plain text input. Default. | All |
| Email input. Validates format. Mobile shows @ keyboard. | Modern | |
| password | Hidden text input. Characters masked. | All |
| number | Numeric input. Spinner buttons. Mobile shows number keyboard. | Modern |
| range | Slider control. Good for ages, ratings, volume. | Modern |
| date | Date picker. Format: YYYY-MM-DD. | Modern |
| time | Time picker. Format: HH:MM. | Modern |
| datetime-local | Date and time picker. No timezone. | Modern |
| color | Color picker. Returns hex value. | Modern |
| checkbox | Toggleable option. Multiple can be selected. | All |
| radio | Mutually exclusive option. Only one per group can be selected. | All |
| file | File upload. Use accept to limit file types. |
All |
| submit | Submit button. Submits the form. Use <button> instead. |
All |
| reset | Reset button. Clears form fields. | All |
| button | Generic button. No default action. Use with JavaScript. | All |
| search | Search input. Mobile shows search keyboard. | Modern |
| tel | Telephone input. Mobile shows phone keyboard. | Modern |
| url | URL input. Validates format. Mobile shows URL keyboard. | Modern |
Master HTML from the ground up.
Build semantic, accessible web pages.
Join the Best AI Programs β three 5-month courses, fully online, with placement assistance. Week 1 is free.
Explore our AI-era courses β