Skip to main content
Sitemap

Last updated

Every HTML element

HTML is a semantic language. Nearly every element provides a specific meaning to its contents or function. This is a quick reference for what those meanings are.

Well-written HTML will use the most appropriate element for the job, but you don't need to know every single element from memory!

I highly encourage you to use your browser's find-in-page feature on this page.


<a>:
the Anchor Link element

Text semantics

Short for ‘anchor’. A link that, when clicked, directs the user to a different page or to the id of an element on a page. The text of the link should be descriptive of where it leads.

<a href="mission.html">About our mission</a>

If submitting a form or activating custom functionality, use a button, instead.


<abbr>:
the Abbreviation element

Text semantics

An acronym or abbreviation. Define both the abbreviation and its expanded meaning within the element.

Director of the <abbr>Cohost Enclave Space Agency (CESA)</abbr>

Avoid expanding upon the abbreviation in the title attribute, as users of touch screens or some assistive technologies won’t be able to view it.


<acronym>:
the Acronym element

Obsolete

Was used for marking up acronyms. Use abbr instead.


<address>:
the Contact Details element

Text semantics

Container indicating that the enclosed content is contact information for the author of the page content.

<h2>Contact beeps</h2>
<address>
  Email: hi@berly.kim<br>
  Website: beeps.website<br>
  Fediverse: @beeps@social.beeps.gay
</address>

Note that an address is specifically about the content author, and not arbitrary postal addresses or contact information.


<applet>:
the Java Applet element

Embedded content

Obsolete

Non-standard element that embedded a Java applet within the page. Superseded by the standardised object element, before Java applets stopped being supported entirely.


<area>:
the Image Area element

Image maps

Defines a clickable region within a map, defined using the shape, coords and href attributes.

If shape="rect", the coords value is the starting X and Y axes coordinates, followed by the ending X and Y axes coordinates.

If shape="circle", the coords value is the X and Y axes coordinates at the centre of the circle, followed by the circle’s diameter.

If shape="poly", the coords value is any number of X and Y axes coordinates provided in pairs.

All coordinates are expressed in pixel values, starting from the top-left of the image, and separated by commas.

Image maps usually have poor accessibility and cannot scale up or down if the size of the image is altered. They should generally be avoided.


<article>:
the Article element

Sections of a page

An independent, self-contained section of content, such that it could be separated from the surrounding context and still make sense. Common examples include articles, blog posts, forum posts and comments.

Articles may contain their own header and footer elements, which will be scoped to the article. For example, to contain the title, publish date and other metadata about the article.

<article>
  <header>
    <h1>Vogon poetry</h1>
    <time datetime="1979-10-12">12 October 1979</time>
  </header>
  <p>
    Oh freddled gruntbuggly,<br>
    Thy micturitions are to me,<br>
    As plurdled gabbleblotchits,<br>
    On a lurgid bee,<br>
    That mordiously hath blurted out,<br>
    Its earted jurtles, grumbling<br>
    Into a rancid festering confectious organ squealer.<br>
  </p>
  <footer>
    <p>Written by Prostetnic Vogon Jeltz</p>
  </footer>
</article>

<aside>:
the Aside element

Sections of a page

A section of content that is indirectly related to the primary content, such that removing it would not compromise understanding the content. Common examples include decorative pullquotes and tangents to the main content.


<audio>:
the Audio element

Media

An embedded audio file, defined using the src attribute or one or more source elements.

By default, the element renders invisibly. The controls attribute must be included to provide visible playback controls.

Any HTML inside of the element, that aren’t source elements, will be displayed if the browser or device is incapable of audio playback.

<audio controls>
  <source src="golden-record.mp3" type="audio/mp3">
  <a href="golden-record.mp3">Download a recording of Voyager's Golden Record</a>
</audio>

track elements can be used to provide transcriptions and translations of audio content.


<b>:
the Bring Attention To element

Text semantics

Text that requires visual prominence, but is not important in the context of the content. Common examples include the name of a product in a review or a person’s name in a biography.

5, 4, 3, 2, 1... <b>Blast off!</b>

If the text is important to the content, use strong. For headings, use h1h6.


<base>:
the Base URL element

Metadata

Defines the base URL for a document. This instructs the browser to rewrite all relative URLs within the page (such as links and images) using the base element’s href attribute as its starting point.

This element is most useful if a page has been moved to a different URL, but references on the page, such as links and images, still expect it to be in the previous location.


<basefont>:
the Base Font element

Metadata

Obsolete

Specified the default font family, size and colour to use on a document. Like font, but it automatically applied to everything.

These days, you can just use CSS.


<bdi>:
the Bidirectional Isolate element

Text semantics

Tells the browser that the contained text is written in a different direction (right-to-left or left-to-right) to the surrounding text, so that the browser knows to switch directions. For example, an Arabic name written in an English language article.

Modern browsers are usually quite capable of working this out themselves, however this element may be useful if the two are heavily intertwined.


<bdo>:
the Bidirectional Override element

Text semantics

Tells the browser that the contained text should be written in a specific direction, which may differ from what the browser would normally assume. The direction to use is specified by setting the dir attribute to either ltr or rtl.

There’s usually very little reason to use this, but it’s there.


<bgsound>:
the Background Audio element

Media

Obsolete

Non-standard element that embedded automatically playing audio onto a page.

Functionally replaced by the audio element. Very annoying and not supported by modern browsers. Don’t even consider it.


<big>:
the Bigger Text element

Obsolete

Was used to render text slightly larger than its surrounding text, back when CSS wasn’t really a thing yet. Today, use CSS font-size: larger instead.



<blockquote>:
the Block Quotation element

Grouping content

Container indicating that the enclosed text is a quotation from a third-party, typically rendered separately from non-quoted content.

<blockquote>
  <p>
    We go to the moon and do the other things, not because they are easy, but because they are hard.
  </p>
</blockquote>

For quotations inline with other text, use q.

If the quote has a citation, this should appear outside of the blockquote element, such as in a figcaption, with both the blockquote and figcaption wrapped in a figure. Use the cite element if it’s appropriate to your needs.


<body>:
the Document Body element

Sections of a page

Surrounds all ‘visible’ content on a webpage. That is, all content that would normally be displayed to a user.

All webpages must contain a body element, even if it’s empty, and there can only be one body element. If omitted, the browser will try to insert one when rendering the page.


<br>:
the Line Break element

Text semantics

Adds a line break into the flow of text, forcing subsequent text to begin on a new line.

Don’t use for producing distinct paragraphs, for paragraphs, use p. For lists of items, use ol or ul.


<button>:
the Button element

Forms

An interactive element that, once activated, performs an action.

<button type="submit">Launch</button>
<button type="reset">Abort</button>
  • For buttons with a type of submit, the default behaviour is to submit the form the button is contained within. If there is no form element, this does nothing.
  • For buttons with a type of reset, the default behaviour is to revert the form to the state it was when the page was originally loaded.
  • For buttons with a type of button, there is no default behaviour. Functionality must be added using JavaScript or other HTML attributes.

If a type isn’t specified, a button’s default type is submit.


<canvas>:
the Canvas element

Scripting

A rendering context specific for use with the Canvas API (for 2D graphics) and WebGL API (for 2D and 3D graphics).

Doesn’t really do anything by itself.


<caption>:
the Table Caption element

Tables

The title or caption of a table. A table may only have one caption.

The caption must be the first element in the table. The location of the caption can be changed using the caption-side CSS property.

<table>
  <caption>Atmospheric composition of solar system planets</caption>
  ...
</table>

Providing a caption isn’t required, but is useful for providing a succinct description of the table for assistive technology users.


<center>:
the Centered Text element

Obsolete

Was used to render content in the middle of the page, back when CSS wasn’t really a thing yet.

Today there are multiple ways of doing this in CSS, including text-align, auto margins, and flexbox.


<cite>:
the Citation element

Text semantics

The name of the creative work that is being cited by the surrounding text. For example, the name of a book, specification, television program, website, etc.

<blockquote>
  <p>The boundary condition of the universe is that it has no boundary.</p>
  <p>&mdash; Stephen Hawking, <cite>A Brief History of Time</cite></p>
</blockquote>

Cite is only intended for the name of the work, rather than the names of authors or other metadata like publishing date or page numbers, but it’s one of those things that no one really cares that much about.


<code>:
the Code element

Text semantics

A snippet of computer code. code does not escape HTML, so any content within the element that would normally be parsed as HTML, such as < and > characters, need to be manually escaped.

The code element can be combined with pre to create multi-line code blocks.


<col>:
the Table Column element

Tables

A mechanism for passing HTML attributes to the columns in a table without having to repeat them for each table cell. Cols can only be used within a colgroup.

<table>
  <colgroup>
    <col class="first-column">
    <col span="2" class="other-columns">
  </colgroup>
  <thead>
    <tr>
      <th>Rocket</th>
      <th>Liftoff thrust</th>
      <th>Mass to LEO</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>Saturn V</th>
      <td>34,500 kN</td>
      <td>140 tonnes</td>
    </tr>
  </tbody>
</table>

col elements are applied on the inline axis (for example, left-to-right in English, right-to-left in Arabic). If you want to skip a column, add a col element with no attributes.


<colgroup>:
the Table Column Group element

Tables

Container for a list of col elements within a table. A table may only contain one colgroup.


<data>:
the Data element

Text semantics

Along with the value attribute, provides a machine-readable version of the content within the element, such as an ID for a user or product.

Find out <data value="42">the Answer to Life, the Universe, and Everything</data>

There is no specification for how scripts consume this information. It is up to the webpage author and the data consumer to agree on the standard.

For providing machine-readable dates and times, use time instead.


<datalist>:
the Data List element

Forms

Container for a list of option elements, representing suggested data for use with other form inputs.

Datalists must have an id attribute. Form inputs can then reference the data list using the list attribute.

<input type="time" list="launch-times">
<datalist id="launch-times">
  <option value="9:00">
  <option value="11:00">
  <option value="13:00">
  <option value="22:00">
</datalist>

Currently, only certain types of input support data lists, and each one presents the suggestions differently. See the datalist examples on MDN.

Data lists don’t require the user to use a suggested value. If the user’s options should be restricted, use radio input elements or the select element.


<dd>:
the Definition Detail element

Grouping content

A value for the preceding dt within a dl. There can be more than one dd element associated with a single dt.


<del>:
the Deleted Text element

Text semantics

Text that has been removed from a document, usually rendered ‘struck through’. A datetime attribute can be added to provide information on when it was removed.

The Higgs-Boson has <del datetime="2013-03-14">not</del> been proven to exist. 

Screen readers do not announce the presence of del elements, so you may want to use custom CSS to provide additional context.

The companion to ins, which is for text that has been added to a document. If something has been stricken entirely, use s.


<details>:
the Details element

Interactive elements

Container element for a disclosure widget that can show or hide content on a page. This can be useful for hiding content that is only relevant to a subset of users.

<details>
  <summary>Transcript of Kennedy's address at Rice University</summary>
  <p>I appreciate your president having made me an honorary visiting professor, and I will assure you that my first lecture will be very brief.</p>
</details>

Content is hidden by default. Add the open HTML attribute to have it start open.

Details should include a summary element that describes the content. All content within the details element other than the summary will be shown and hidden when interacting with it.


<dfn>:
the Definition element

Text semantics

A word or phrase that is being defined, such as in a dictionary or glossary of terms.

It should be used as part of a p, section, or dt/dd pairing.

<p>The period of maximum dynamic pressure, commonly referred to as <dfn>max q</dfn>, is the most dangerous part of a spacecraft's launch.</p>

<dialog>:
the Dialog element

Interactive elements

Container element for content that appears in a dialog (variably known as a ‘modal’, ‘modal window’ or ‘lightbox’). Dialogs appear ‘above’ the content of a page and can optionally prevent interaction with the rest of the page until the user makes an action that closes the dialog.

Useful examples of dialogs include confirmations that a user wants to do something, or certain multitasking situations, such as writing an email whilst still navigating around their inbox. Less useful examples include cookie consent dialogs and newsletter sign up forms.

Dialogs can be opened and closed using JavaScript, or by using HTML command and commandfor attributes.

<button command="show-modal" commandfor="confirm-dialog">Launch rocket</button>

<dialog id="confirm-dialog">
  <p>Are you sure about that?</p>
  <form>
    <button type="button" command="close" commandfor="confirm-dialog">Abort!</button>
    <button type="submit">Launch!</button>
  </form>
</dialog>

<dir>:
the Directory List element

Obsolete

Was used to render a nested list of files and folders, similarly to the file system on a computer. Use nested ul elements instead.


<div>:
the Content Division element

Grouping content

One of the two generic HTML elements, divisions do not have any specific meaning associated with them. They can be used for any purpose where a more appropriate element doesn’t exist.

Content divisions can contain any other HTML element normally allowed within page content.


<dl>:
the Definition List element

Grouping content

A container for a list of keys and values, defined by a single dt followed by one or more dd elements.

Each set of dt and dd elements may optionally be wrapped in a div for ease of styling.

<dl>
  <div>
    <dt>Orbital speed</dt>
    <dd>24.07 km/s</dd>
  </div>
  <div>
    <dt>Satellites</dt>
    <dd>Phobos</dd>
    <dd>Deimos</dd>
  </div>
</dl>

<dt>:
the Definition Term element

Grouping content

A key within a dl, with one or more dd elements following it.


<em>:
the Emphasised Text element

Text semantics

Text with stress emphasis, such as a word or words that would normally be said in a different tone of voice when spoken aloud.

Now is <em>not</em> the time for this!

<embed>:
the Embedded Media element

Embedded content

Used for embedding external content into a page, usually from an external application or a browser plugin, in conjunction with object.

Historically, this was commonly used for embedding Flash and Java content but has fallen out of use since. It has largely been superseded in modern times by more discrete elements like canvas, audio, and video.


<fencedframe>:
the Fenced Frame element

Embedded content

Experimental

A restricted alternative to iframe that intends to better preserve user privacy without breaking the iframe element’s backwards compatibility.

This element is experimental and isn’t widely supported yet.


<fieldset>:
the Field Set element

Forms

Used to group together multiple related inputs within a form, usually accompanied by a legend.

This is particularly common with checkboxes and radio buttons, but may apply to any group of several inputs, such as when asking for an address.

<fieldset>
  <legend>Select your favourite <i>Star Trek</i> captain</legend>
  <input type="radio" name="captain" id="kirk"> <label for="kirk">James T. Kirk</label>
  <input type="radio" name="captain" id="picard"> <label for="picard">Jean Luc Picard</label>
</fieldset>

Avoid nesting multiple fieldset elements, as screen readers can struggle to announce these correctly.


<figcaption>:
the Figure Caption element

Grouping content

A caption for a figure element. The figcaption should always be the first or last element within the figure.


<figure>:
the Figure element

Grouping content

A self-contained piece of content, optionally with a caption, that is referenced by the surrounding content but where the position of it is irrelevant to understanding the content.

Figures can contain any kind of content, but common examples include images, charts and diagrams.

Figures may have a figcaption. If present, the figcaption element must be the first or last element in figure.

<figure>
  <img src="saturn-v-schematic.jpg" alt="A black and white illustration of a large rocket ship, presented sideways with a cutaway showing the internal workings of the rocket.">
  <figcaption>A schematic of the Saturn V rocket's internal systems.</figcaption>
</figure>

Including a figcaption can be beneficial to screen reader users, as it provides context on what the figure contains.


<font>:
the Font element

Obsolete

Was used to dictate the appearance of text, prior to the creation and widespread implementation of CSS. Use font-family, font-size, and color in CSS today.



<form>:
the Form element

Forms

Container element for form inputs. The form element typically dictates a form’s behaviour and where the form’s content should be sent when the form is submitted.

<form action="submit.php" method="POST">
  <label for="countdown">Seconds to launch</label>
  <input type="number" name="seconds" id="countdown">
  <button type="submit">Start countdown</button>
</table>

<frame>:
the Frame element

Obsolete

Represented an HTML document within a frameset.


<frameset>:
the Frame Set element

Obsolete

Container for multiple frame elements, which could be composited together to build a webpage out of multiple HTML documents.

The frameset element replaced the body element when used.

Due to issues with performance and accessibility, framesets are obsolete and not all browsers support displaying them.


<h#>:
the Heading element

Sections of a page

The heading elements—h1, h2, h3, h4, h5, and h6—represent a descending hierarchy that is used to structure the content that follows them.

Heading levels should descend in order throughout the document, without skipping levels, however they may jump to a prior level at any time.

Webpages should only have a single h1 element, which contains the name of the page. All other headings should use one of the lower heading levels.

<h1>The Space Shuttles</h1>

<h2>Enterprise</h2>
<h3>Development history</h3>
<h4>Test flights</h4>

<h2>Columbia</h2>
<h3>Construction</h3>
<h3>Flights</h3>
<h3>Destruction</h3>



<hgroup>:
the Heading Group element

Sections of a page

Groups together a heading (h1h6) with related content, such as a subtitle, version number or revision date.

An hgroup can only contain a single heading, and other content must be contained within p elements.

<hgroup>
  <h1>Address at Rice University on the Nation's Space Effort</h1>
  <p>aka, "We choose to go to the moon"</p>
</hgroup>
<p>...</p>

<hr>:
the Thematic Break element

Grouping content

Represents a thematic break between paragraphs, such as the start of a new topic or a change of scene in a story.

<p>The astronauts' last meal on Earth was steak and eggs, with coffee and a slice of cake.</p>
<hr>
<p>As they began to board the capsule...</p>

This is typically rendered as a horizontal line, but CSS can be used to change the appearance or to visually hide the line.


<html>:
the HTML Document element

Sections of a page

Surrounds all other HTML content, including the head and body. There can only be one html element.

The html element should include the page’s language in the lang attribute, written as a IETF language subtag. This helps search engines provide results in the user’s language and helps screen readers know how to pronounce the page’s content.

<html lang="en">
  ...
</html>

<i>:
the Idiomatic Text element

Text semantics

Represents text that is offset from normal text for readability purposes, such as terms borrowed from other languages, technical terms, and the names of publications, creative works, and vehicles.

Unlike em, i does not convey any difference in tone of voice.

One of the Space Shuttles, edited to resemble OV-101 <i>Enterprise</i>, appears in the opening sequence of <i>Star Trek: Enterprise</i>.

<iframe>:
the Inline Frame element

Embedded content

Embeds a different webpage within the current page. This is commonly used for including content hosted on other websites, such as YouTube videos.

<iframe width="560" height="315" src="https://www.youtube.com/embed/niZpcdp2v34">
  <p><a href="https://www.youtube.com/watch?v=niZpcdp2v34">View this video on YouTube</a></p>
</iframe>

Any content within the iframe’s opening and closing tags will be shown to the user if their browser is unable to render the frames.


<img>:
the Image element

Media

Embeds an image into the document.

Images should include an alt attribute that succinctly describes the contents of the image.

<img src="saturn.jpg" alt="Close up photograph of the planet Saturn, with a particular focus on the planet's ring system." width="600" height="470">

Only a subset of image formats are widely supported by web browsers. These are JPEG, PNG, GIF, SVG, WebP and AVIF.

Adding width and height attributes helps browsers know how large the image will be before it has finished loading, helping the page to render faster.


<input>:
the Input element

Forms

Inserts an interactive control that can accept input from a user and send it to a server. The appearance, functionality, and restrictions of an input are determined by the type attribute.

Inputs must be within a form and have a name attribute to send their data to a server. Inputs should have a label element associated with them that describes what the user is expected to enter or select.

It is one of the most powerful and complex HTML elements.

The text type

The default, text allows a user to type a single line of arbitrary content.

You can provide a hint to a browser about how to autofill the value by setting the autocomplete attribute to an accepted autocomplete value.

The maximum length of the content can be restricted by setting a maxlength attribute.

<input type="text" name="surname" autocomplete="family-name" value="Shepard">

If values longer than one line are accepted, use the textarea element instead.

The password type

Similar to the text type, but the value is visually obscured from the user.

Browsers and password managers will often attempt to automatically fill the value of a password field. You can control this behaviour by setting the autocomplete value to either current-password (to prompt autofilling), or new-password (to prompt generating a new password). For security reasons, most browsers don’t allow you to disable this functionality.

<input type="password" name="launch-code" autocomplete="current-password" value="hunter2">

The email, tel, and url types

All variants of the text type, these appear visually identical to text but show different default keyboards on touchscreen devices, may be autofilled differently, and have different validation rules when browser validation is being used.

The number and range types

Allows the user to enter a number. The number type presents the user with a text box with up and down arrow buttons for setting a value without typing. The range type presents the user with a slider, with the value set by dragging instead.

The lower and upper bounds of the value can be set with the min and max attributes. The intervals a value may change by can be set with the step attribute, and can also be used to allow fractional values.

<input type="number" name="apollo" min="1" max="17">

The date, time, datetime-local, and week types

Allows the user to enter a calendar date, time, date and time, or week.

Browsers will usually also provide a calendar interface to pick a date and a list of hours and minutes for times, as well as allowing typing.

Browsers adapt the format to match the user’s language and locale (for example, rendering as MM/DD/YYYY in the United States and DD/MM/YYYY in most other English-speaking locales).

Date values are sent to the server in ISO 8601 format.

  • Dates: YYYY-MM-DD, for example, 1969-07-16.
  • Times: hh:mm, in the 24-hour clock, for example, 13:32.
  • Datetimes: The above formats, with a T inserted as a separator. For example, 1969-07-16T13:32. Note that this doesn’t include a timezone, which must be determined separately.
  • Weeks: The year followed by -W and the week number. for example, 1969-W29.

The earliest and latest values a user may choose can be set with the min and max values, using the same ISO 8601 formatting.

<input type="date" name="launch-date" min="1962-09-12" max="1969-12-31">

The color type

Displays a button filled with a particular colour. Clicking the button displays the browser or operating system’s colour picker interface.

Colour inputs usually only support the sRGB colour space and returns values in hexadecimal format,like #0b3d91.

The checkbox and radio types

Renders selection boxes for a list of options. Checkboxes allow multiple options to be chosen, whereas radio buttons only allow one.

These options should all have the same name attribute, individual labels, and be wrapped within a fieldset.

Both checkboxes and radios may be pre-selected by passing the checked attribute.

<fieldset>
  <legend>Which of these was the first woman in space?</legend>
  <div>
    <input type="checkbox" name="answer" id="answer-1" value="jemison">
    <label for="answer-1">Mae Jemison</label>
  </div>
  <div>
    <input type="checkbox" name="answer" id="answer-2" value="ochoa">
    <label for="answer-2">Ellen Ochoa</label>
  </div>
  <div>
    <input type="checkbox" name="answer" id="answer-3" value="ride">
    <label for="answer-3">Sally Ride</label>
  </div>
  <div>
    <input type="checkbox" name="answer" id="answer-4" value="sharman">
    <label for="answer-4">Helen Sharman</label>
  </div>
  <div>
    <input type="checkbox" name="answer" id="answer-5" value="tereshkova">
    <label for="answer-5">Valentina Tereshkova</label>
  </div>
</fieldset>

The file type

Displays a button for a user to select a file from their device.

Adding the multiple attribute allows users to select multiple files. The accept attribute allows you to define a list of file formats the user can select.

The capture attribute alters the behaviour of the input, instead prompting the user to use their device camera to capture a photograph, video or audio recording instead of selecting one.

Unlike other input types, setting value does nothing on the file type.

<input type="file" name="photograph" accept="image/jpeg,image/png" multiple>

The button, submit and reset types

These work identically to the button element. See that element for information.

An input with these types can only show plain text text, whereas the button element can display a wide range of HTML elements, usually making it preferable.

The image type

Shows a button with an image in it. This is largely unused in the modern era. Use a button with CSS or an img element instead.

If you want a user to upload an image, use the file type instead.

The hidden type

An invisible input that holds read-only information to be sent to the server along with other inputs.

Avoid relying on hidden inputs for critical functionality, as tech savvy users can still view and edit the values of hidden inputs.


<ins>:
the Inserted Text element

Text semantics

Text that has been added to a document at a later point. A datetime attribute can be added to provide information on when it was added.

VY Canis Majoris is the <ins datetime="2006">second</ins> largest star in the Milky Way.

The companion to del, which is for text that has been removed from a document.


<isindex>:
the Index Page element

Metadata

Obsolete

Non-standard element that prompted browsers to offer ‘find in page’ functionality for the given page.

Was never well supported and was made obsolete by browsers providing ‘find in page’ functionality on all webpages.


<kbd>:
the Keyboard Input element

Text semantics

Represents typed input within content, such as keys the user can press as part of a shortcut, or commands in command line interfaces.

Press <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Delete</kbd> and select the reboot option, or open the command line and type <kbd>shutdown /r<kbd>.

<keygen>:
the Key Generation element

Forms

Obsolete

Generated a public and private key used for encrypting data when submitting forms, with the public key being sent with the form data and the private key stored on the user’s device.

Was not consistently supported across browsers.


<label>:
the Label element

Forms

Represents the label for a form control, such as input, select, or textarea.

label elements are typically associated to the form control using a for attribute that matches the id of the associated element. The control may also be wrapped in the label element, though this tends to limit styling options.

A label should only be associated with a single form control, and every control should have a label.

<label for="name-suggestion">Suggest a name for the star</label>
<input type="text" id="name-suggestion">

To provide a ‘label’ for a group of inputs, such as checkboxes or radio buttons, use a fieldset and legend.


<legend>:
the Field Set Legend element

Forms

Provides an optional heading for a fieldset. If used within a field set, it must be the first child element.

The experimental customisable select specification also allows placing legends within the optgroup, in lieu of using the label attribute.


<li>:
the List Item element

Lists

A singular list item within an ol, ul, or menu.

In ordered lists (ol), they may optionally have a value attribute to override the normal list number.



<listing>:
the Code Listing element

Text semantics

Obsolete

Rendered pre-formatted text, maintaining whitespace and line breaks from the source code.

Today, use the pre element instead.


<main>:
the Main element

Sections of a page

Represents the dominant content of the page.

A page can only have one main element, and it should not be nested within any elements that are semantically significant. Only the following elements are valid ancestors of main:


<map>:
the Image Map element

Image maps

Surrounds one or more area elements. Along with the name attribute and an img (or rarely, an object), it can be used to create an image with multiple interactive regions.

<map name="my-solar-system">
  <area alt="Square Planet" shape="rect" href="square.html" coords="0,0,50,50">
  <area alt="Poly Planet" shape="poly" href="poly.html" coords="10,10,30,0,40,50,10,40">
  <area alt="Orb Planet" shape="circle" href="orb.html" coords="25,100,25">
</map>

<img usemap="my-solar-system" src="system.jpg" alt="My Solar System">

Image maps usually have poor accessibility and cannot scale up or down if the size of the image is altered. They should generally be avoided.


<mark>:
the Mark Text element

Text semantics

A piece of text that should be highlighted because of its relevance to the current context, for example, words the user has searched for in a list of search results.

<h1>Search results for "rocket"</h1>

<h2>A brief history of <mark>rocket</mark> science</h2>
<p>In the beginning, there were no <mark>rocket</mark>s. There were barely even aircraft, with flight being a domain solely restricted to nature. We wouldn't invent the basic idea of a <mark>rocket</mark> until Wan Hu strapped 47 fireworks to a chair and tried to launch himself into space. Thus, the <mark>rocket</mark> was born.</p>

mark is only to highlight content relevant to the user’s current context. To highlight text as being important, use strong. To emphasise text generally, use em.


<marquee>:
the Marquee element

Obsolete

Allowed content to scroll vertically or horizontally across the screen. Use CSS animations instead.




<meta>:
the Metadata element

Metadata

Typically represents metadata about the page’s content, though it may also be used for some technical metadata. meta elements normally appear inside of the head element.

The most common use cases for meta are to define the page’s character set and to provide supplementary information about the content.

<head>
  <meta charset="utf-8">
  <meta name="description" content="An extensive history of the NASA Space Shuttles.">
  <meta name="keywords" content="space shuttle, nasa, enterprise, endeavour, discovery, challenger, columbia, atlantis">
</head>

<meter>:
the Meter element

Forms

Provides a read-only visual representation of a value within a numerical range.

The lower and upper bounds are provided using the min and max attributes, respectively. The current value is provided using the value attribute.

Any text inside of the meter element is announced by screen readers and used as a fallback for browsers that cannot display the element. As it’s technically a form control, meter should have an accompanying label element.

<label for="lox">Liquid oxygen remaining</label>
<meter id="lox" min="0" max="553358" value="449658">81.26% remaining</meter>

Optional low and high attributes can be specified to change the default appearance of the meter after certain points, such as appearing in red when the value is less than low and green when it’s more than high.

An optional optimal attribute may also be set to indicate the ideal range. If the value of optimal is between min and low, it means that lower values are preferred. If it’s between high and max, higher values are preferred.

Meter is intended for showing a relatively static representation of a value. To show a visual representation of progression, such as though a process or file upload, use progress. To accept user input using a visual range, use input with the range type.


<multicol>:
the Multiple Column element

Obsolete

Formatted content within it in multiple columns, based on the value of the cols attribute, before CSS was really a thing.

Today, this can be achieved using the column-count CSS property.



<nextid>:
the NeXT ID element

Obsolete

A non-standard element that was proprietary to the NeXT web editor, the first HTML code editor. It instructed the editor which number to begin with when automatically generating id attributes for page headings and tables of contents. Here’s a page explaining the history and use of nextid if you’re interested.

Has the distinction of being the first element to be removed from the HTML specification. Obviously does not work in any modern browser or HTML code editor.


<nobr>:
the Non-Breaking Text element

Text semantics

Obsolete

The antithesis to br, content contained in nobr tags would not wrap onto new lines or render with line breaks.

A non-standard element from the days before CSS. Today, use text-wrap-mode: nowrap instead.


<noembed>:
the Embedded Media Fallback element

Embedded content

Obsolete

Rendered fallback content for browsers that did not support embed elements.

Much like embed, it’s largely obsolete these days. Fallback content is now provided as part of the object element instead.


<noframes>:
the Frame Fallback element

Frames

Obsolete

Provided fallback content for browsers that don’t support frame and frameset.

Like frames, pretty much obsolete and unused today.


<noscript>:
the JavaScript Fallback element

Scripting

Provides fallback content for browsers that do not support JavaScript or where JavaScript execution has been disabled by the user.

<canvas id="cool-interactive-map-thing"></canvas>
<script src="cool-interactive-map-thing.js"></script>

<noscript>
  <img src="map.png" alt="Fallback map image">
</noscript>

Notably, noscript content does not display for browsers where JavaScript is available but scripts failed to load or run. You need to handle those use cases yourself.


<object>:
the External Object element

Embedded content

Represents an external file to embed within the page. The data and type attributes are required.

Any content inside of the object, except for embed and param elements, will be used as fallback content in case the embedded media is unable to be displayed.

<object data="launch-footage.webm" type="video/webm" width="600" height="140">
  <img src="/launch-photo.jpg" alt="A rocket mid-launch above the pad, bright flames lighting up the night sky." />
</object>

Although still valid, it has largely been replaced by discrete elements like canvas, audio, and video.


<ol>:
the Ordered List element

Lists

Surrounds a list of li where the order of the items is significant to the content, that is, where changing the order of the items would alter how they’re understood. For example, the steps in a recipe or a list of comments that are replies to one another.

<ol>
  <li>Build the rocket</li>
  <li>Fuel up the rocket</li>
  <li>Launch the rocket</li>
</ol>

Use the start attribute to define a starting point other than 1. Use the reversed boolean attribute to display numbers in descending order.

For lists of items where the order is not significant, use ul. For lists of key-value pairs, use dl. For lists of controls, use menu.


<optgroup>:
the Option Group element

Forms

Creates a group of options within a select element. A name can be given to the group using the label attribute.

<label for="probes">Select a space probe</label>
<select id="probes">
  <optgroup label="Jovian">
    <option value="galileo">Galileo</option>
    <option value="voyager1">Voyager I</option>
    <option value="voyager2">Voyager II</option>
  </optgroup>
  <optgroup label="Saturnian">
    <option value="cassini">Cassini</option>
  </optgroup>
  <optgroup label="Plutonian">
    <option value="new-horizons">New Horizons</option>
  </optgroup>
</select>

<option>:
the Option element

Forms

Represents a distinct option within a select or datalist element.

If used within a select element, the selected attribute can be provided to determine a default choice, otherwise it will default to the first option provided.

If a value attribute is not provided, then the value is implied to be the same as the option’s text label.

<label for="shuttles">Select your favourite shuttle</label>
<select id="shuttles">
  <option>Atlantis</option>
  <option>Challenger</option>
  <option>Columbia</option>
  <option selected>Discovery</option>
  <option>Endeavour</option>
  <option>Enterprise</option>
  <option value="none">I prefer rockets</option>
</select>

<output>:
the Output element

Forms

Contains the outcome of a user action, such as changing the value of form controls. The contents are typically changed dynamically using JavaScript.

The for attribute contains a space-separated list of input ids that affect the final output.

<label for="name">Enter your name</label>
<input type="text" id="name" value="John">

<label for="town">Enter the name of your town or city</label>
<input type="text" id="town" value="Columbus">

<output for="name town">Hello John from Columbus!</output>

Many assistive technologies will announce the content of output automatically when it’s changed, without requiring users to move focus to the element.

Only intended for the actual outputs of an operation. For examples of outputs, use samp.


<p>:
the Paragraph element

Grouping content

Unsurprisingly, surrounds a paragraph of content.

<p>Many years ago, the great British explorer George Mallory, who was to die on Mount Everest, was asked why did he want to climb it? He said, “Because it is there.”</p>
<p>Well, space is there, and we’re going to climb it.</p>

You pretty much always want to surround sizable blocks of text in a p, as it allows assistive technology users to rapidly move between paragraphs of text. Don’t use multiple br elements to emulate paragraphs, and don’t use empty p elements to emulate spacing—use CSS instead.


<param>:
the Object Parameter element

Embedded content

Obsolete

Represented metadata within object elements.

This has since been replaced by attributes on the object element itself.


<picture>:
the Picture element

Media

A container for an img and any number of source elements, that allows for conditionally changing the image being displayed by the img based on screen resolution, viewport size, and browser support.

picture must contain a single img element, which comes last in the element. This img is used as a fallback if the browser doesn’t support the picture element or none of the provided sources are able to be used.

Unlike the similar looking audio and video elements, picture is only a container. All attributes relating to the image, like classes or alt text, must be placed on the img element, not the picture element.

<picture>
  <!-- Used if the browser supports AVIF images -->
  <source srcset="apollo-11.avif" type="image/avif">
  
  <!-- Used if the browser window is taller than it is wide --> 
  <source srcset="apollo-11-portrait.jpg" media="(orientation: portrait)">
  
  <!-- Used if the browser window is wider than 1000 pixels and the image takes up 100% of the viewport width -->
  <source srcset="apollo-11-wide.jpg" media="(min-width: 1000px)" sizes="100vw" width="1000">
  
  <!-- Provides multiple resolutions of the same image, depending on the display's pixel density -->
  <source srcset="apollo-11@3x.jpg 3x, apollo-11@2x.jpg 2x, apollo-11.jpg">
  
  <!-- Fallback image and where you put your attributes -->
  <img src="apollo-11.jpg" width="300" height="600" alt="Photograph of the Apollo 11 Saturn V rocket mid-launch, taken from the top of the launch tower.">
</picture>

Using picture is only beneficial if you’re leveraging its ability to replace the source image, otherwise, it’s simpler to use img.


<plaintext>:
the Plain Text element

Text semantics

Obsolete

Displayed everything after it as pre-formatted text, not parsing HTML and maintaining the whitespace and line breaks of the source code. Weirdly, plaintext had no closing tag, so it effectively stopped a page from rendering once used. Weird.

Use the pre element with manually escaped HTML tags instead.


<pre>:
the Preformatted Text element

Grouping content

Represents text that should be presented exactly as written, without collapsing or removing spaces, tabs, and line breaks.

If pre is being used to produce a visual, such as ASCII art, then it should be hidden from assistive technologies and furnished with a text alternative as though it were an image. You can use figure and figcaption for this purpose.

<figure>
<!-- Because `pre` preserves spaces, we don't want to indent anything inside of it. -->
<pre aria-hidden="true">
     ________________________________
    /                                "-_
   /      .  |  .                       \
  /      : \ | / :                       \
 /        '-___-'                         \
/_________________________________________ \
     _______| |________________________--""-L
    /       F J                              \
   /       F   J                              L
  /      :'     ':                            F
 /        '-___-'                            /
/_________________________________________--"
</pre>
  <figcaption>An ASCII drawing demonstrating how wormholes bend space time, by Henry Segerman.</figcaption>
</figure>

pre is often used in conjunction with code to display code snippets.


<progress>:
the Progress Indicator element

Forms

Provides a visual representation of how complete a task is.

The upper bound is provided by the max attribute, with the lower bound being fixed at 0. The current value is provided using the value attribute, but may be omitted if there is an indeterminate amount of progress remaining, such as uploading a file when you don’t know how large the file is.

Text inside of the progress element is announced by screen readers and shown as a fallback for browsers that cannot display the element. As it’s technically a form control, progress should have an accompanying label element.

<label for="altitude-to-orbit">Distance to orbit</label>
<progress id="altitude-to-orbit" max="370" value="226">61.1% of the way to orbit</progress>

progress is only intended to show progression when there is a distinct start and end point. To show a visual representation of other values, use meter. To accept user input using a visual range, use input with the range type.


<q>:
the Inline Quotation element

Text semantics

Encloses a quotation that is inline with other, non-quoted text content.

<p>It was Carl Sagan who famously said <q>The cosmos is also within us. We're made of star-stuff. We are a way for the cosmos to know itself.</q> in the 1990 edition of <i>Cosmos</i>.</p>

For quotations that stand by themselves, like pullquotes, use blockquote instead.


<rb>:
the Ruby Base element

Ruby text

Obsolete

Delimited the text having an annotation applied to it within a ruby element.

It is no longer necessary to delimit the base text, with the base text able to be a direct child of ruby.


<rp>:
the Ruby Fallback Parenthesis element

Ruby text

Is used to separate parentheses or other punctuation intended to discern an annotation within a ruby element. Typically used in conjunction with rt.

These fallbacks are only shown in browsers that don’t support Ruby text, ensuring that Ruby annotations remain separate from the text they’re annotating.


<rt>:
the Ruby Text element

Ruby text

Represents the text of an annotation within a ruby element.

Typically used in conjunction with rp, which separates annotations from the text being annotated.


<rtc>:
the Ruby Text Container element

Ruby text

Obsolete

Provided a semantic annotation for the content of ruby elements, in contrast with the rt element’s pronunciation annotations.

Semantic annotations should now appear outside of the ruby element.


<ruby>:
the Ruby Annotation element

Ruby text

Allows for the addition of rt annotations that are presented alongside the text. This is common in East Asian typography to provide guidance for how to pronounce ideographs, though it may have other uses, such as for displaying word-by-word translations.

Browsers that support Ruby annotations will typically display the annotation in small text above the associated word. Browsers that don’t will instead show the annotation afterwards. rp elements may be used to provide separating punctuation (often, parentheses) for non-supporting browsers.

<p>JAXA successfully launched the <ruby lang="jp">明かり <rp>(</rp><rt>Akari</rt><rp>)</rp></ruby> satellite in February 2006.</p>

Has nothing to do with the Ruby programming language.


<s>:
the Strikethrough element

Text semantics

Represents text that is no longer relevant or accurate.

There is significant overlap between s and del elements. del is intended for marking up changes to documents that are revised in place, such as changes to articles on Wikipedia. Meanwhile, s is more generically for text that is no longer accurate.

Buy an acre of land on Mars for just <s>$34.99</s> $29.99!

If it has been removed as part of a round of edits, use del. If it’s a stylistic choice, use CSS and text-decoration: line-through instead.

Screen readers do not announce the presence of s elements, so you may want to use custom CSS to provide additional context.


<samp>:
the Sample Output element

Text semantics

Encloses text that is quoted from, or indicative of, the output of a program.

In the event that Panel F7 reads <samp>HYD PRESS</samp>, the hydraulics system pressure has exceeded minimum or maximum limits.

samp is intended for static output samples. For showing the actual output of a program that is running or has just been run, use output instead.


<script>:
the Script element

Scripting

Allows for the addition of behavioural scripts to the page, practically always JavaScript. script is typically used in one of two ways: with a src attribute, or inline.

The src attribute references a separate file to the current page. The browser will begin loading this file when the renderer first encounters it, and will execute it immediately once loaded.

<body>
  [...]
  <script src="starry-cursor-trail-code.js"></script>
</body>

JavaScript code can also be written inline, directly inside of the script element.

<body>
  [...]
  <script>
    const launchButton = document.getElementById("launch-button")
    launchButton.addEventListener("click", () => {
      alert("Launch button is broken. Sorry!")
    })
  </script>
</body>

Script elements cannot contain both inline code and a src attribute. If you need a mixture of both, use multiple script elements.

The script element is ‘render blocking’, meaning the browser stops and waits for scripts it encounters to load and run before continuing to render the rest of the page, making pages seem to load slower. You usually want to put script elements as one of the last things inside of your body element so that everything else loads before it, or you can use the defer attribute to delay loading instead.



<section>:
the Generic Section element

Sections of a page

Represents a section of a document that doesn’t have a more specific element to represent it.

Sections should always contain a heading or an accessible label that identifies the section’s content.

<section>
  <h2>Astronauts</h2>
  [...]
</section>

<section aria-label="Cosmonauts">
</section>

<h2 id="taikonauts-heading">Taikonauts</h2>
<section aria-labelledby="taikonauts-heading">
</section>

There are many, many more semantic alternatives to section. For a non-exhaustive list of examples:

  • For navigation elements, use nav.
  • For wrapping the primary content of the page, use main.
  • For the main heading of a page, or headings within a section, use header.
  • For the main footer of a page, or metadata within a section, use footer.
  • For a piece of content that makes sense outside of the context of the rest of the page, use article.
  • For content that is supplemental to the page’s content, use aside.
  • For search functionality, use search.

If you’re looking for an element solely to use as a styling hook, use div.


<select>:
the Select element

Forms

Allows a user to select an option from a list. By default, a user can only select a single option and one option must always be selected. These options may be grouped into optgroups.

<label for="planets">Your one absolutely most favourite planet</label>
<select id="planets">
  <option>Mercury</option>
  <option>Venus</option>
  <option>Earth</option>
  <option>Mars</option>
  <option>Jupiter</option>
  <option>Saturn</option>
  <option>Uranus</option>
  <option>Neptune</option>
</select>

The appearance and functionality of select elements differs between browsers and operating systems, but is most commonly displayed as a list below the select or overlaid on the page.

Selects have many usability and accessibility issues, especially if the multiple attribute is used. It’s better to treat a select as an ‘input of last resort’ and try to gather input using an alternative method, such as radio inputs instead.


<selectedcontent>:
the Selected Option Display element

Forms

Experimental

Contains the content of the currently selected option within a select, if customised selects are being used.

<!-- Note that this style is what enables customised selects. Doesn't work without it. -->
<style>
  select { appearance: base-select; }
</style>

<label for="fave">What's your favourite nebula?</label>
<select id="fave">
  <button>
    <selectedcontent></selectedcontent>
  </button>
  <option value="crab">
    <img alt="" src="https://assets.science.nasa.gov/dynamicimage/assets/science/missions/hubble/releases/2026/03/STScI-01KJQWS2TX2REXHGQ32X7EJ7V1.jpg?fit=clip&crop=faces%2Cfocalpoint&w=300">
    Crab Nebula
  </option>
  <option value="eagle">
    <img alt="" src="https://assets.science.nasa.gov/dynamicimage/assets/science/missions/hubble/nebulae/emission/STScI-01EVT1KKAFJAP21ZQTE56GWAXS.png?fit=clip&crop=faces%2Cfocalpoint&w=300">
    Eagle Nebula
  </option>
  <option value="egg">
    <img alt="" src="https://assets.science.nasa.gov/dynamicimage/assets/science/missions/hubble/releases/2026/02/STScI-01KAEVP71560HQNPJMT2ZC0GA6.jpg?fit=clip&crop=faces%2Cfocalpoint&w=300">
    Egg Nebula
  </option>
</select>

<slot>:
the Web Component Slot element

Scripting

slot, along with template, is part of the Web Components suite of technologies. They represent an area where content can be injected into a web component, based on a given name attribute.

Content inside of the slot element is displayed as a fallback if no content has been injected into it.

<template id="planet-details">
  <p>The planet <slot name="name">Noname</slot> is <slot name="diameter">0 kilometers</slot> in diameter and home to <slot name="population">no</slot> humans.</p>
</template>

[...]

<planet-details>
  <strong slot="name">Earth</strong>
  <span slot="diameter">approximately 12,756 kilometres</span>
  <span slot="population">roughly 8 billion</span>
</planet-details>

<small>:
the Small Print element

Text semantics

Does what it says on the tin, small represents small print like copyright notices, legal declarations, disclaimers, and attributions.

<p>You too can own a genuine piece of the Moon for only $99.99 <small>plus $26 billion postage and packaging, sales tax not included</small></p>

<source>:
the Media Source element

Media

Specifies a media resource to use with audio, video, and picture elements.

When used with audio and video, source elements typically include src and type attributes that link to the media files and describe what the media type of the file is. Browsers will select the earliest listed source that the browser and operating system supports playback for.

<audio controls width="500" height="40">
  <source src="apollo-11-radio.webm" type="audio/webm">
  <source src="apollo-11-radio.mp3" type="audio/mp3">
</audio>

When used with picture, source elements typically have a srcset, width, and height attributes.

Multiple sources utilising the media attribute can be useful for dynamically replacing an image depending on the size and shape of the browser window.

<picture>
  <source srcset="apollo-11-landscape.jpg" width="1500" height="700" media="(orientation: landscape)">
  <source srcset="apollo-11-portrait.jpg" width="500" height="1000" media="(orientation: portrait)">
  
  <img src="apollo-11-portrait.jpg" width="300" height="600" alt="Photograph of the Apollo 11 Saturn V rocket mid-launch, taken from the top of the launch tower.">
</picture>

src and srcset attributes are not interchangeable: audio and video elements must always use src and picture elements must always use srcset.


<spacer>:
the Spacer element

Obsolete

Inserted empty space into the page, based on its width and height attributes, before CSS was a thing.

Today, use CSS properties like margin to do this.


<span>:
the Content Span element

Grouping content

One of the two generic HTML elements, spans do not have any specific meaning associated with them. They can be used for any purpose where a more appropriate element doesn’t exist.

Unlike div, spans are considered text elements and may only contain other text elements.


<strike>:
the Stricken Text element

Text semantics

Obsolete

Rendered text ‘crossed out’, in the days before CSS was a thing.

If the text is irrelevant, use s. If it has been removed as part of a round of edits, use del. If it’s a stylistic choice, use CSS and text-decoration: line-through instead.


<strong>:
the Strong Importance element

Text semantics

Represents text that is important, relative to the other content.

<strong>If the alarm sounds, inform CAPCOM immediately.</strong> Otherwise, enjoy the launch!

For text that should have visual prominence, but isn’t important to the content, use b.


<style>:
the Style element

Metadata

Allows for inserting CSS style rules directly into the current page. CSS inserted using style has a higher priority than CSS in external stylesheets, but lower priority than elements with inline style attributes.

<style>
  .earth {
    color: azure;
  }
</style>

<div class="earth" aria-label="A pale blue dot.">.</div>

This can be used anywhere on the page, but best practice is to include it in the head so that the browser renderer encounters it sooner. This avoids the browser having to restart rendering the page when it encounters new style elements.

To link to an external stylesheet, use link.


<sub>:
the Subscript element

Text semantics

Inline text that needs to be displayed in subscript (below the text baseline) for typographical reasons, such as chemical formulae.

<p>The availability of water, or H<sub>2</sub>O, is necessary for humans to live in space.</p>

Companion to sup, the superscript element.


<summary>:
the Details Summary element

Interactive elements

The persistent, visible label for a details element.


<sup>:
the Superscript element

Text semantics

Inline text that needs to be displayed in superscript (above the text baseline) for typographical reasons, such as mathematical formulae.

<p>Einstein's theory of relativity stated that E=MC<sup>2</sup>.</p>

Companion to sub, the subscript element.


<svg>:
the Scalable Vector Graphic element

Embedded content

Scalable Vector Graphics are image files that can be embedded directly within HTML, rather than being included from an external file.

svg and its children belong to a separate specification and not strictly HTML elements, but are a reasonably common sight to see on webpages. See MDN’s list of SVG elements for references on all of those.


<table>:
the Table element

Tables

Element that wraps around tabular data—content that’s being presented as a set of rows and columns.

<table>
  <caption>The inner planets of the Sol system</caption>
  <colgroup>
    <col class="name">
    <col span="2" class="align-right">
  </colgroup>
  <thead>
    <tr>
      <th scope="col">Planet name</th>
      <th scope="col">Distance from sun (AU)</th>
      <th scope="col">Radius (km)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Mercury</th>
      <td>0.450</td>
      <td>2,439.7</td>
    </tr>
    <tr>
      <th scope="row">Venus</th>
      <td>0.725</td>
      <td>6,051.8</td>
    </tr>
    <tr>
      <th scope="row">Earth</th>
      <td>1.000</td>
      <td>6,371.0</td>
    </tr>
    <tr>
      <th scope="row">Mars</th>
      <td>1.525</td>
      <td>3,389.5</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <th scope="row">Average</th>
      <td>0.9275</td>
      <td>4,563.0</td>
    </tr>
  </tfoot>
</table>

Tables have several unique elements used for defining their content:

  • tr wraps around each row.
  • th contains column and row headings.
  • td contains tabular data.
  • thead, tbody, and tfoot separates the table’s header and footer rows from the main content.
  • caption provides an overview of the table contents.
  • colgroup and col help to make styling columns easier.

Don’t use tables for laying out content. That’s not what they’re for and it can mess up assistive technology users.


<tbody>:
the Table Body element

Tables

Surrounds the main content of a table. This will typically contain multiple tr elements, each containing one or more th and td elements.

If a table lacks a tbody element, the browser will implicitly insert one.


<td>:
the Table Data element

Tables

A cell of data contained within a table. Must be the child element of a tr.

Avoid leaving cells empty, as this can confuse users of some assistive technologies. Add text such as ‘Not applicable’ if there’s no data available.


<template>:
the Content Template element

Scripting

Container that can hold snippets of HTML code without the code being rendered on the page.

This is useful for when working with JavaScript and Web Components, as it allows HTML to be pulled directly from the page and avoids needing to manually recreate the HTML in JavaScript.


<textarea>:
the Textarea element

Forms

An interactive control that can accept multiple lines of input from a user and send it to a server.

The cols and rows attributes may be used to define the textarea’s size, but the element’s dimensions are best defined in CSS these days.

<label for="application">Why do you want to be an astronaut?</label>
<textarea id="application" name="reason" rows="10" cols="120"></textarea>

Compare to the input element’s text type, which only accept a single line of input.


<tfoot>:
the Table Footer element

Tables

Surrounds the footer tr elements of a table. Usually this will be the row or rows that summarise the table’s content, such as providing totals or averages.


<th>:
the Table Heading element

Tables

A cell, containing text that acts as a title to the current column or row of data, contained within a table. Must be the child element of a tr.

Which axis the th relates to should be specified using the scope attribute.

If the text is not a heading to the adjacent data, use the td element instead. If it’s acting as a heading for the entire table, use caption.


<thead>:
the Table Header element

Tables

Surrounds the header tr elements of a table. Usually this will be the row or rows that define the headings for each column.


<time>:
the Time element

Text semantics

Represents a human readable (and optionally, machine readable) date and/or time. Often used as part of metadata, such as when a post was published or updated.

<time>20 July 1969</time>

A machine readable version of the date can be provided using the datetime attribute. This must use the ISO 8601 datetime format.

<time datetime="1969-07-20T20:17:40Z">20 July 1969 at 8:17pm UTC</time>

<title>:
the Page Title element

Metadata

The title of the page, as displayed in the browser user interface (tab, window title, browsing history, etc.)

The title should be reasonably descriptive of the page’s content and may be split into sections to reproduce the site’s content hierarchy. Because the start of the title is less likely to be cut off when displayed in the browser, it should contain the information most unique to the current page.

The title can only contain plain text and HTML entities, not other HTML elements. The title element must always be inside of the head element.

<head>
  <title>
    The Apollo 13 incident &mdash; Apollo missions &mdash; beeps' cool moon
    mission site
  </title>
</head>

<tr>:
the Table Row element

Tables

Container for the table cells elements, th and td, and delineates where each row of data begins and ends.

tr elements must be contained within a thead, tbody or tfoot element.


<track>:
the Text Track element

Media

Provides accessible text alternatives and other metadata to audio and video, such as adding closed captions, audio description, or chapter information.

Text tracks are provided as files in WebVTT format.

<video controls>
  <source src="video.webm" type="video/webm">
  <track src="captions-en.vtt" kind="captions" srclang="en" label="English">
  <track src="subtitles-en.vtt" kind="subtitles" srclang="en" label="English">
  <track src="subtitles-sv.vtt" kind="subtitles" srclang="sv" label="Svenska">
  <track src="subtitles-jp.vtt" kind="subtitles" srclang="jp" label="日本語">
</video>

The kind attribute describes what kind of data the file contains. These can be:

  • subtitles: Transcription or translation of speech, intended for users who can hear but don’t understand the content’s original language.
  • captions: Transcription or translation of speech, sounds and music, intended for users who are deaf or hard of hearing.
  • descriptions: Descriptions of the visual components of a video, intended for users who are blind. (It is expected that the browser or other software announces the descriptions.)
  • chapters and metadata: Provides other metadata to the video player. These don’t normally do anything by default, and require you to write additional code to make work.

The srclang attribute describes the language of the text alternative, using an IETF language subtag. The label attribute is the description that will be shown on the player’s track selector.


<tt>:
the Teletype Text element

Text semantics

Obsolete

Displayed text in a monospace font, akin to teletype machines, before CSS was really a thing.

These days, use the font-family CSS property to define a monospace font, or one of the many semantic alternatives if they fit your use case:

  • code for code snippets.
  • kbd for keyboard inputs.
  • samp for sample outputs.
  • var for variables.

<u>:
the Unarticulated Annotation element

Text semantics

Represents text that has an annotation that isn’t explicitly described. For example, indicating a spelling error or applying proper name marks.

Two possibilities exist: <u>eizher</u> we are alone in the Universe or we are not. Both are equally terrifying.

Although the default styling of this element is an underline, you shouldn’t use it to create generic underlined text, use text-decoration: underline in CSS instead.


<ul>:
the Unordered List element

Lists

Surrounds a list of li where the order of the items is irrelevant, that is, where changing the order of the items wouldn’t alter how they’re understood. A shopping list, for example.

<ul>
  <li>Sally Ride</li>
  <li>Nancy Grace Roman</li>
  <li>Margaret Hamilton</li>
  <li>Mae Jameson</li>
</ul>

For lists of items where the order is important to the meaning, use ol. For lists of key-value pairs, use dl. For lists of controls, use menu.


<var>:
the Variable element

Text semantics

Represents the name of a variable in mathematics and programming contexts.

The total energy required to move something (<var>E</var>) is equal to the mass of the object (<var>m</var>) multiplied by the speed of light squared (<var>c</var><sup>2</sup>).

To represent code snippets, use code. For a keyboard key, use kbd. For example output of a process, use samp, or for actual output use output.


<video>:
the Video element

Media

An embedded video file, defined using the src attribute or one or more source elements.

By default, the video renders without any controls. The controls attribute must be included to provide visible playback controls.

Any HTML inside of the element, that aren’t source elements, will be displayed if the browser or device is incapable of playing the video.

<video controls>
  <source src="artemis-1-launch.mp4" type="audio/mp4">
  <source src="artemis-1-launch.webm" type="audio/webm">
  <a href="artemis-1-launch.mp4">Download a recording of the Artemis I (SLS) launch.</a>
</video>

track elements can be used to provide captions, subtitles, and audio description of video content.


<wbr>:
the Word Break Opportunity element

Text semantics

Represents an opportunity to insert a line break, if one is required to avoid the text overflowing the element.

Useful for long, compound words that might be displayed in a constrained space, allowing you to define word boundaries where it’s least disruptive for the reader.

The German Space Agency has their own interest in starting a <span lang="de">Weltraum<wbr>schrott<wbr>beseitigungs<wbr>programm</span>. 

wbr will not introduce a hyphen when it breaks across lines. Use a soft hyphen (&shy;) instead of wbr if you want line breaks to be hyphenated.


<xmp>:
the eXtensible Markup Presentation element

Text semantics

Obsolete

Rendered its contents as plain text, not parsing any HTML or collapsing whitespace characters, for the purposes of displaying code snippets.

Like plaintext, but could be closed this time.

Use the pre and code elements with manually escaped HTML tags instead.