HTML reference
Every HTML tag with its description, attributes and examples you see right away in a live preview. From document structure to forms, tables and media.
145 entries
Document structure
The skeleton of a page: the document, the head with metadata, styles and scripts.
- <html>The root of an HTML document. Every other element on the page lives inside it.
- <head>The invisible part of the document holding metadata: the title, character encoding, description, styles, and scripts.
- <body>The visible part of the document: everything the user sees on the page and can interact with.
- <title>The document title shown on the browser tab, in bookmarks, and as the headline of a search result.
- <meta>Page metadata: character encoding, mobile viewport settings, a description for search engines, and a link preview on social networks.
- <link>Connects the document to an external resource: a stylesheet, a page icon, a font, or another language version.
- <style>A CSS stylesheet written directly in the HTML document.
- <script>Embeds JavaScript code in the page or loads it from a file to give the page behavior.
- <noscript>Content the browser shows only when JavaScript is turned off.
- <base>Sets the base address for all relative addresses in the document and the default target of links.
- <!DOCTYPE html>The document type declaration on the first line of the file. It tells the browser to render the page in standards mode rather than quirks mode.
- <!-- … -->A comment in HTML code: a note for humans that the browser doesn’t display, although anyone can see it in the page source.
Sections and semantics
Elements that split a page into logical parts and describe what they mean.
- <article>Self-contained content that makes sense read or shared on its own.
- <section>A thematic part of a document, usually with its own heading.
- <header>An introduction to a page or section: logo, title, navigation, author info.
- <footer>A page or section’s footer: author, copyright, links, contact info.
- <main>The page’s main, unique content. Only one should be visible per page.
- <nav>A block of primary navigation links: a menu, a table of contents, breadcrumbs.
- <aside>Tangential content loosely related to its surroundings: a callout box, a sidebar, a note.
- <h1>-<h6>Headings at six levels, from the most important h1 to the least important h6. Together they form the page’s outline.
- <hgroup>Groups a heading together with a subtitle, tagline, or kicker.
- <address>Contact information for an article’s author or a site’s owner.
- <search>Marks the part of a page that holds a search box or result filters.
Text and formatting
Paragraphs, links, emphasis, quotes and tags for pieces of code.
- <a>A link to another page, a file, an email address, or a place on the same page.
- <p>A paragraph of text.
- <strong>Text of great importance: a warning, key information.
- <br>A line break at the point it’s inserted, without starting a new paragraph.
- <hr>A thematic break in content, for example a scene change in a story or a shift to a different topic.
- <pre>Preformatted text: it preserves spaces, tabs, and line breaks exactly as they appear in the code.
- <blockquote>A longer quotation from another source, displayed as a separate, indented block.
- <div>A generic block-level container with no meaning, for grouping elements and styling.
- <span>A generic inline container with no meaning, for styling a piece of text.
- <em>Stress in a sentence: a word that, read aloud, is pronounced with emphasis.
- <b>Draws attention to a piece of text without giving it any extra weight, e.g. keywords.
- <i>Text in a different tone or voice: foreign expressions, Latin names, a character’s thoughts, technical terms.
- <u>Text with an annotation that can’t be expressed in words, most often a spelling-error mark.
- <s>Content that’s no longer accurate, such as an old price. The browser strikes it through.
- <small>Fine print: disclaimers, legal notices, copyright, and short side notes.
- <mark>Highlights a piece of text like a highlighter, because it’s relevant in the current context.
- <abbr>An abbreviation or acronym, with an optional expansion in the title attribute.
- <cite>The title of a work: a book, an article, a movie, a song, a game, or a piece of software.
- <code>A piece of computer code: the name of a variable, function, tag, or file, as well as a short listing.
- <kbd>Input entered by the user: keys, keyboard shortcuts, and commands to type.
- <samp>Sample output from a program: a message, a console response, or error text.
- <var>A variable in a math formula or a program, as well as a placeholder symbol in a command.
- <sub>Subscript: text lowered and shrunk, for example in chemical formulas.
- <sup>Superscript: text raised and shrunk, for example exponents and footnote numbers.
- <time>A date, time, or duration written clearly for people and, at the same time, understandably for machines.
- <data>Links human-readable content to a machine value, for example a product name with its code.
- <q>A short quote woven into a sentence. The browser adds the quotation marks itself.
- <dfn>A term being defined at this point in the text, that is, the first, explanatory use of the concept.
- <bdi>Isolates a piece of text whose writing direction is unknown, e.g. a username written in Arabic.
- <bdo>Forces the text’s display direction, bypassing the automatic bidirectional algorithm.
- <wbr>A spot where the browser may break a long word or string of characters when the line runs out of room.
- <ins>Text added to a document, for example in a new version of a terms page or a corrected article.
- <del>Text removed from a document, shown struck through to preserve the history of changes.
- <ruby>Ruby annotations: small text above characters, most often the pronunciation of Chinese or Japanese characters.
- <rt>The annotation text in a ruby element: pronunciation or meaning displayed above the base text.
- <rp>Fallback parentheses around a ruby annotation, visible only where ruby isn’t supported.
Lists
Bulleted, numbered and description lists.
- <ul>A bulleted list in which the order of the items doesn’t matter.
- <ol>A numbered list in which the order of the items matters.
- <li>A single item of a `<ul>`, `<ol>`, or `<menu>` list.
- <dl>A description list: name and description pairs, for example a glossary of terms or technical data.
- <dt>A name, term, or question in a `<dl>` description list.
- <dd>The description or value assigned to a `<dt>` name in a description list.
- <menu>A list of commands, for example a toolbar with buttons. It works like `<ul>`.
Tables
Data in rows and columns, with headers, a caption and groups.
- <table>A table with data arranged in rows and columns.
- <caption>The title of a table, placed as the first element inside `<table>`.
- <thead>A group of rows with the table’s column headers.
- <tbody>The main part of a table: a group of rows with data.
- <tfoot>A table footer: rows with a summary, totals, or notes on the columns.
- <tr>A table row that contains `<th>` and `<td>` cells.
- <th>A table header cell: the name of a column or row.
- <td>A regular table cell with data.
- <colgroup>A group of table columns that you can style in one go.
- <col>One or more columns in a `<colgroup>`, for styling a whole column at once.
Forms
Fields, buttons, select lists and everything users send data with.
- <form>A form that collects data from the user and sends it to a given address.
- <input>A form field: text, email, password, number, date, slider, checkbox, file and many more.
- <label>A form field’s label. Clicking the label moves the cursor to the field.
- <button>A clickable button: submits a form, clears it, or runs an action on the page.
- <select>A dropdown list the user picks one or more options from.
- <option>A single option in a `<select>` list, or a suggestion in a `<datalist>`.
- <optgroup>A named group of options inside a `<select>` list.
- <textarea>A multi-line text field for longer input: messages, reviews, descriptions.
- <fieldset>A group of related form fields with a border and a `<legend>` caption.
- <legend>The caption of a `<fieldset>` group of fields, displayed on its border.
- <datalist>A list of suggestions for an `<input>` field. You can pick a proposal or type your own value.
- <output>The result of a calculation or a user action, for example a total in a calculator.
- <progress>A progress bar for a task: uploading a file, an installation, or course completion.
- <meter>A gauge for a value within a known range: disk space used, a test score, battery level.
Images and media
Images, graphics, audio, video and their captions.
- <img>An image embedded in the page.
- <picture>A container for several versions of an image. The browser picks the one that best fits the screen and format.
- <source>An alternative source of an image, audio, or video for `<picture>`, `<audio>`, and `<video>`.
- <figure>A self-contained illustration with an optional caption: an image, chart, code snippet, or quote.
- <figcaption>The caption of an illustration inside a `<figure>` element.
- <audio>An audio player: a podcast, a narration, a sound effect.
- <video>A video player embedded directly in the page.
- <track>A file with subtitles, descriptions, or chapters for `<video>` and `<audio>`.
- <canvas>A canvas for drawing bitmap graphics with JavaScript.
- <svg>Vector graphics written directly in the page code: icons, logos, charts.
- <map>An image map: clickable regions defined by `<area>` elements.
- <area>A clickable region of an image map: a rectangle, circle, or polygon with its own address.
Embedded content
Frames and objects that put another page or resource on your page.
Interactive elements
Disclosure sections, dialogs and templates without a single line of JavaScript.
- <details>A collapsible section: the `<summary>` heading is always visible, and the rest of the content appears on click.
- <summary>The always-visible heading of a `<details>` element, which expands and collapses the content.
- <dialog>A dialog or modal window: a confirmation, form, or message shown above the rest of the page.
- <template>An invisible HTML template that a script copies and inserts into the page.
- <slot>A placeholder in a web component where the content written between its tags ends up.
Global attributes
Attributes you can add to any tag: class, id, style, hidden and more.
- classA list of class names that CSS and JavaScript use to find an element.
- idA unique identifier for an element across the whole document.
- styleCSS styles written directly on an element.
- titleExtra information about an element, usually shown as a tooltip.
- langThe language of the element’s content, for example pl or en.
- dirText direction: left to right, right to left, or automatic.
- hiddenHides an element: the browser neither displays nor exposes it.
- tabindexDecides whether an element can be focused with the Tab key and in what order.
- data-*Custom attributes for storing data for scripts and styles.
- contenteditableLets the user edit the element’s content directly on the page.
- draggableSpecifies whether an element can be dragged with the mouse.
- spellcheckTurns spell checking on or off in editable text.
- popoverTurns an element into a pop-up opened by a button, without JavaScript.
- inertDisables interaction with an element and its descendants: clicking, focus and screen readers.
- accesskeyA keyboard shortcut that moves focus to an element or activates it right away.
- autofocusSets focus on an element right after the page loads or after a dialog opens.
- autocapitalizeTells the on-screen keyboard when to capitalize: never, at the start of a sentence, at the start of a word, or always.
- enterkeyhintChanges the label or icon of the Enter key on the on-screen keyboard, for example to “Search”, “Send” or “Next”.
- inputmodeHints which on-screen keyboard to show: digits, digits with a decimal separator, a phone pad, an email keyboard, or none.
- translateLets you turn off automatic translation of a part of the page, for example a brand name or code.
- roleAn ARIA role tells screen readers what an element is: a button, a tab, a message, navigation.
- aria-*ARIA attributes describe elements for screen readers: they give them names, link them to descriptions and report their state.
- onclickRuns JavaScript code when an element is clicked. The simplest, but not the best way to handle events.
- oninputRuns JavaScript code on every change of a field’s value: after typing a character, pasting text or moving a slider.
- onchangeRuns JavaScript code when the user commits a new field value: picks an option, ticks a checkbox or finishes typing.
- onsubmitRuns JavaScript code right before a form is submitted. Lets you stop the submission and handle the data in a script.
- onkeydownRuns JavaScript code the moment a key is pressed. Used for keyboard shortcuts and for handling keys such as Enter or Escape.
- onloadRuns JavaScript code when a resource has finished loading: the whole page, an image, a frame, a script or a stylesheet.
Comparisons
How similar tags differ and when to pick each one.
- <div> vs <span><div> is a block-level container with no meaning, and <span> is its inline counterpart. Both exist only for grouping and styling, never to describe content.
- <section> vs <article> vs <div><article> is self-contained content, <section> is a thematic part of something larger, and <div> is a neutral container with no meaning at all.
- <strong> vs <b><strong> marks content that is important, urgent or serious. <b> only draws attention to a piece of text, without adding any weight. Visually, both are bold.
- <em> vs <i><em> is stress that changes the meaning of a sentence when read aloud. <i> marks a different tone: foreign words, names or thoughts, without changing meaning.
- class vs idclass can repeat across many elements and combine several at once. id must be unique across the whole document and is used for anchors, labels and JS.
- <button> vs <a><button> performs an action on the page, e.g. submitting a form. <a> navigates: it changes the address or opens a resource. Both work with the keyboard.
- <header> vs <head><head> is an invisible section holding the page’s metadata, one per document. <header> is a visible introductory element, and a page can have several.