Skip to content

Reference · 115 tags

HTML Tags List with Examples

Every tag in HTML as it is now, with what it does, the attributes you’ll need and a tiny example you can copy. Click “Show result” to see an example live. Old tags like <center> and <font> are at the end, with what to use instead.

Page structure & metadata

The frame of every page, and the tags in the head that tell the browser about the page. None of the head tags show on the page itself.

  • <html>

    The root of the page. Every other tag goes inside it.

    Attributes: lang the page language, like en

    Example
    <!doctype html>
    <html lang="en">
      <head><title>My page</title></head>
      <body>Hello!</body>
    </html>
  • <head>

    Holds information about the page: its title, styles and meta tags. Nothing in here shows on the page.

    Attributes: only the global ones, like id, class and lang

    Example
    <head>
      <meta charset="utf-8">
      <title>My page</title>
      <link rel="stylesheet" href="style.css">
    </head>
  • <title>

    The page name shown in the browser tab and as the big link in search results.

    Attributes: only the global ones, like id, class and lang

    Example
    <title>Pixel Bakery: fresh bread every day</title>
  • <meta>

    void · no closing tag

    Page details for browsers and search engines: the character set, the viewport, the description.

    Attributes: charset the text encoding, always utf-8 name which detail, like description content its value http-equiv acts like an HTTP header (rare)

    Example
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Fresh bread, baked every morning.">
  • <style>

    CSS written right inside the page.

    Attributes: media only for some screens, like print

    Example
    <style>
      h1 { color: #4d7c0f; }
    </style>
  • <base>

    void · no closing tag

    Sets the starting address for every relative link on the page. You rarely need it.

    Attributes: href the base address target where links open by default

    Example
    <base href="https://example.com/docs/">
  • <body>

    Everything people see on the page goes in here.

    Attributes: only the global ones, like id, class and lang

    Example
    <body>
      <h1>Hello!</h1>
      <p>Welcome to my page.</p>
    </body>

Page sections & headings

Tags that give a page its outline. They look like plain boxes, but they tell browsers, screen readers and search engines what each part is.

  • <header>

    The top of a page or a section: a logo, a title, maybe a menu.

    Attributes: only the global ones, like id, class and lang

    Example
    <header>
      <h1>Pixel Bakery</h1>
      <p>Fresh bread since 1998</p>
    </header>
  • <nav>

    A block of main navigation links, like your site menu.

    Attributes: aria-label a name, when a page has more than one nav

    Example
    <nav>
      <a href="/">Home</a>
      <a href="/menu">Menu</a>
      <a href="/contact">Contact</a>
    </nav>
  • <main>

    The main content of the page, without the header, menu and footer. Use one per page.

    Attributes: only the global ones, like id, class and lang

    Example
    <main>
      <h1>Our bread</h1>
      <p>Sourdough, rye and more.</p>
    </main>
  • <article>

    A piece that makes sense on its own: a blog post, a news story, a product card, a comment.

    Attributes: only the global ones, like id, class and lang

    Example
    <article>
      <h2>How we bake sourdough</h2>
      <p>It starts the night before.</p>
    </article>
  • <section>

    A part of a page about one topic, usually with its own heading.

    Attributes: only the global ones, like id, class and lang

    Example
    <section>
      <h2>Opening hours</h2>
      <p>Every day, 7 to 3.</p>
    </section>
  • <aside>

    Content that's related but not the main point: a sidebar, a tip box, a pull quote.

    Attributes: only the global ones, like id, class and lang

    Example
    <aside>
      <h3>Did you know?</h3>
      <p>Rye bread stays fresh for days.</p>
    </aside>
  • <h1> to <h6>

    Headings, from h1 (the most important) down to h6. Use one h1 for the page title and don’t skip levels.

    Attributes: only the global ones, like id, class and lang

    Example
    <h1>Page title</h1>
    <h2>A section</h2>
    <h3>A smaller part</h3>
  • <hgroup>

    Groups a heading with a subtitle or tagline that belongs to it.

    Attributes: only the global ones, like id, class and lang

    Example
    <hgroup>
      <h1>Pixel Bakery</h1>
      <p>Fresh bread since 1998</p>
    </hgroup>
  • <address>

    Contact details for the person or team behind the page or an article.

    Attributes: only the global ones, like id, class and lang

    Example
    <address>
      Pixel Bakery<br>
      12 Baker Street<br>
      <a href="mailto:[email protected]">[email protected]</a>
    </address>

Text blocks & lists

Paragraphs, lists, quotes and the plain boxes you group things with. These are block elements: each starts on a new line.

  • <p>

    A paragraph of text. Browsers add a little space above and below it.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>This is a paragraph.</p>
    <p>And this is another one.</p>
  • <div>

    A plain box with no meaning, for grouping things so you can style or position them.

    Attributes: class a name for your CSS id a unique name

    Example
    <div class="card">
      <h3>Sourdough</h3>
      <p>$6</p>
    </div>
  • <hr>

    void · no closing tag

    A break between topics, shown as a horizontal line.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>That's the end of part one.</p>
    <hr>
    <p>Part two starts here.</p>
  • <pre>

    Text shown exactly as typed: every space and line break stays, in a monospace font.

    Attributes: only the global ones, like id, class and lang

    Example
    <pre>
    Bread   Price
    Rye     $5
    Cake    $12
    </pre>
  • <blockquote>

    A longer quote from somewhere else, indented by default.

    Attributes: cite the address of the source

    Example
    <blockquote cite="https://example.com/review">
      <p>Best bread in town.</p>
    </blockquote>
  • <ul>

    A bulleted list, for items where the order doesn't matter.

    Attributes: only the global ones, like id, class and lang

    Example
    <ul>
      <li>Flour</li>
      <li>Water</li>
      <li>Salt</li>
    </ul>
  • <ol>

    A numbered list, for steps or rankings where the order matters.

    Attributes: start the first number reversed count down type 1, a, A, i or I

    Example
    <ol>
      <li>Mix the dough</li>
      <li>Let it rise</li>
      <li>Bake for 40 minutes</li>
    </ol>
  • <li>

    One item in a ul, ol or menu list.

    Attributes: value its number, inside an ol

    Example
    <ul>
      <li>One list item</li>
      <li>Another one</li>
    </ul>
  • <menu>

    A list of commands, like a toolbar. It works just like ul.

    Attributes: only the global ones, like id, class and lang

    Example
    <menu>
      <li><button>Copy</button></li>
      <li><button>Paste</button></li>
    </menu>
  • <dl>

    A description list: terms and what they mean, like a glossary or a list of details.

    Attributes: only the global ones, like id, class and lang

    Example
    <dl>
      <dt>HTML</dt>
      <dd>The structure of a web page.</dd>
      <dt>CSS</dt>
      <dd>How the page looks.</dd>
    </dl>
  • <dt>

    The term (the name part) in a description list.

    Attributes: only the global ones, like id, class and lang

    Example
    <dl>
      <dt>Crumb</dt>
      <dd>The soft inside of bread.</dd>
    </dl>
  • <dd>

    The description of a term in a description list.

    Attributes: only the global ones, like id, class and lang

    Example
    <dl>
      <dt>Crust</dt>
      <dd>The hard outside of bread.</dd>
    </dl>
  • <figure>

    A picture, chart, quote or code sample that stands on its own, often with a caption.

    Attributes: only the global ones, like id, class and lang

    Example
    <figure>
      <img src="bread.jpg" alt="A loaf of sourdough" width="240" height="135">
      <figcaption>Our Monday sourdough.</figcaption>
    </figure>
  • <figcaption>

    The caption of a figure. Put it first or last inside the figure.

    Attributes: only the global ones, like id, class and lang

    Example
    <figure>
      <img src="bread.jpg" alt="Fresh rye bread" width="240" height="135">
      <figcaption>Rye, out of the oven at 7.</figcaption>
    </figure>

Inline text

Tags for words inside a sentence: links, bold, italics, code, dates and more. They don’t start a new line.

  • <a>

    A link to another page, a file, an email address or a spot on the same page.

    Attributes: href where the link goes target _blank opens a new tab rel like noopener or nofollow download save the file instead of opening it

    Example
    <a href="https://example.com">Visit example.com</a>
  • <strong>

    Important text, like a warning. Browsers show it in bold.

    Attributes: only the global ones, like id, class and lang

    Example
    <p><strong>Careful:</strong> the oven is hot.</p>
  • <b>

    Draws attention to words without making them more important, like keywords or product names. Shown in bold.

    Attributes: only the global ones, like id, class and lang

    Not deprecated. HTML5 kept b, i, u, s and small and gave each a clear meaning.

    Example
    <p>Mix the <b>flour</b> with the <b>water</b>.</p>
  • <em>

    Stress, the way you’d say a word louder. Shown in italics.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>I <em>really</em> mean it.</p>
  • <i>

    Words in a different voice: a foreign word, a thought, a term, a ship’s name. Shown in italics.

    Attributes: lang the language of a foreign word

    Example
    <p>The bakers call it <i lang="fr">levain</i>.</p>
  • <u>

    Marks text with an underline for a reason, like a spelling mistake. Not for links or emphasis.

    Attributes: only the global ones, like id, class and lang

    People take underlined text for a link, so use it sparingly. For a plain underline, CSS text-decoration: underline is often better.

    Example
    <p>I can't <u>spel</u> today.</p>
  • <s>

    Text that’s no longer right, like an old price. Shown struck through.

    Attributes: only the global ones, like id, class and lang

    Example
    <p><s>$8</s> $6 today only</p>
  • <small>

    Side comments and fine print, like copyright or legal notes. Shown smaller.

    Attributes: only the global ones, like id, class and lang

    Example
    <p><small>Prices include tax.</small></p>
  • <mark>

    Highlighted text, like a highlighter pen or a search match.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>Bake at <mark>220 °C</mark>, not 200.</p>
  • <span>

    A plain inline wrapper with no meaning, for styling part of a sentence.

    Attributes: class a name for your CSS style CSS right on the tag

    Example
    <p>Our <span style="color: #4d7c0f">green</span> logo</p>
  • <br>

    void · no closing tag

    A line break inside text, like in an address or a poem.

    Attributes: only the global ones, like id, class and lang

    For space between paragraphs, use separate p tags instead of several br tags.

    Example
    Pixel Bakery<br>
    12 Baker Street<br>
    Springfield
  • <wbr>

    void · no closing tag

    A spot where the browser may break a long word or address, if it runs out of room.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>example.com/<wbr>a/<wbr>very/<wbr>long/<wbr>path</p>
  • <code>

    A piece of computer code inside a sentence. Shown in a monospace font.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>Use the <code>&lt;br&gt;</code> tag for a line break.</p>
  • <kbd>

    Keys or other input the user types.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.</p>
  • <samp>

    Sample output from a program, like an error message.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>The app said: <samp>File not found</samp></p>
  • <var>

    A variable in math or code. Shown in italics.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>The area is <var>w</var> × <var>h</var>.</p>
  • <sub>

    Subscript: small text below the line, like the 2 in H₂O.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>H<sub>2</sub>O</p>
  • <sup>

    Superscript: small text above the line, for powers, footnotes or 1st.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>E = mc<sup>2</sup></p>
  • <abbr>

    An abbreviation. Put the full words in title.

    Attributes: title the full words

    Example
    <p><abbr title="HyperText Markup Language">HTML</abbr> is fun.</p>
  • <cite>

    The title of a book, film, song, game or other work.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>My favorite film is <cite>The Great Bake</cite>.</p>
  • <q>

    A short quote inside a sentence. Browsers add the quote marks for you.

    Attributes: cite the address of the source

    Example
    <p>She said <q>the bread is ready</q> and left.</p>
  • <dfn>

    The spot where a term is explained for the first time.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>A <dfn>baguette</dfn> is a long, thin French loaf.</p>
  • <time>

    A date or time, with a version computers can read in datetime.

    Attributes: datetime the date as 2026-12-01 or a time as 14:30

    Example
    <p>We open on <time datetime="2026-12-01">December 1</time>.</p>
  • <data>

    A value with a machine-readable version, like a product code.

    Attributes: value the machine-readable value

    Example
    <p>Best seller: <data value="SKU-1042">Rye loaf</data></p>
  • <ins>

    Text that was added in an edit. Usually underlined.

    Attributes: datetime when it changed cite a page that explains why

    Example
    <p>Open until <del>2 pm</del> <ins>3 pm</ins></p>
  • <del>

    Text that was removed in an edit. Shown struck through.

    Attributes: datetime when it changed cite a page that explains why

    Example
    <p>Price: <del>$8</del> <ins>$6</ins></p>
  • <bdi>

    Keeps text whose direction you don’t know, like a user name in Arabic, from mixing up the line.

    Attributes: only the global ones, like id, class and lang

    Example
    <p>Top baker: <bdi>إيان</bdi>, 12 loaves</p>
  • <bdo>

    Forces the text direction, left-to-right or right-to-left.

    Attributes: dir ltr or rtl (needed)

    Example
    <p><bdo dir="rtl">This reads backwards.</bdo></p>
  • <ruby>

    Small notes above characters, mostly for pronunciation in Japanese or Chinese text.

    Attributes: only the global ones, like id, class and lang

    Example
    <ruby>漢<rp>(</rp><rt>kan</rt><rp>)</rp>字<rp>(</rp><rt>ji</rt><rp>)</rp></ruby>
  • <rt>

    The pronunciation text inside ruby.

    Attributes: only the global ones, like id, class and lang

    Example
    <ruby>東<rt>tō</rt>京<rt>kyō</rt></ruby>
  • <rp>

    Brackets around the ruby text, shown only by browsers that can’t do ruby.

    Attributes: only the global ones, like id, class and lang

    Example
    <ruby>日<rp>(</rp><rt>ni</rt><rp>)</rp></ruby>

Images & media

Pictures, video and sound. In the results here, a sample drawing stands in for the image files, and video and sound have no file to play.

  • <img>

    void · no closing tag

    Shows an image.

    Attributes: src the image file alt what the image shows, for people who can’t see it width / height stop the page jumping while it loads loading lazy waits until it’s near the screen

    Example
    <img src="bread.jpg" alt="A loaf of sourdough" width="320" height="180">
  • <picture>

    Gives the browser a choice of image files, like a newer format or a smaller file for phones.

    Attributes: only the global ones, like id, class and lang

    Example
    <picture>
      <source srcset="bread.avif" type="image/avif">
      <img src="bread.jpg" alt="A loaf of sourdough" width="320" height="180">
    </picture>
  • <source>

    void · no closing tag

    One file option inside picture, video or audio. The browser picks the first one it can use.

    Attributes: src the file, in video and audio srcset the image file, in picture type the file type media only for some screens

    Example
    <video controls width="320">
      <source src="clip.webm" type="video/webm">
      <source src="clip.mp4" type="video/mp4">
    </video>
  • <video>

    Plays a video, with the browser’s own play button and controls.

    Attributes: src the video file controls show play, pause and volume poster a picture before it starts muted / loop / autoplay autoplay usually needs muted

    Example
    <video src="clip.mp4" controls width="320" poster="poster.jpg"></video>
  • <audio>

    Plays sound, like music or a podcast.

    Attributes: src the sound file controls show the player loop play again at the end

    Example
    <audio src="song.mp3" controls></audio>
  • <track>

    void · no closing tag

    Subtitles or captions for a video.

    Attributes: src the .vtt file kind subtitles, captions and more srclang the language, like en label the name in the menu

    Example
    <video src="clip.mp4" controls>
      <track src="subs-en.vtt" kind="subtitles" srclang="en" label="English">
    </video>
  • <map>

    An image map: one image with several clickable areas.

    Attributes: name the name usemap points to

    Example
    <img src="floor.png" alt="Shop floor plan" usemap="#shop" width="200" height="100">
    <map name="shop">
      <area shape="rect" coords="0,0,100,100" href="/bakery" alt="Bakery">
    </map>
  • <area>

    void · no closing tag

    One clickable area in an image map.

    Attributes: shape rect, circle or poly coords where it is href where it goes alt the link text

    Example
    <map name="shop">
      <area shape="circle" coords="50,50,40" href="/cafe" alt="Cafe">
    </map>

Embedded content

Other pages, files and drawings placed inside your page.

  • <iframe>

    Shows another web page inside your page, like a map or a video player.

    Attributes: src the page address title what it is, for screen readers width / height its size loading lazy waits until it’s near the screen

    Example
    <iframe src="https://example.com" title="Example site" width="400" height="200"></iframe>
  • <embed>

    void · no closing tag

    Puts an outside file, like a PDF, on the page with the browser’s own viewer.

    Attributes: src the file type the file type width / height its size

    Example
    <embed src="menu.pdf" type="application/pdf" width="400" height="300">
  • <object>

    Puts an outside file on the page, with backup content if it can’t be shown.

    Attributes: data the file type the file type width / height its size

    Example
    <object data="menu.pdf" type="application/pdf" width="400" height="300">
      <a href="menu.pdf">Download the menu</a>
    </object>
  • <svg>

    Vector graphics drawn right in the page. It comes from SVG, a sister language you can write inside HTML.

    Attributes: viewBox the drawing’s own coordinates width / height its size on the page

    Example
    <svg width="100" height="100" viewBox="0 0 100 100">
      <circle cx="50" cy="50" r="40" fill="#a3e635" />
    </svg>
  • <math>

    Math formulas, written in MathML. Current browsers draw it without any library.

    Attributes: display block puts the formula on its own line

    Example
    <math>
      <msup><mi>x</mi><mn>2</mn></msup>
      <mo>+</mo>
      <mn>1</mn>
    </math>

Tables

Rows and columns for data, like prices or a timetable. Use CSS for page layout, not tables.

  • <table>

    A table of rows and columns, for data.

    Attributes: only the global ones, like id, class and lang

    Build one with the HTML Table Generator →

    Example
    <table>
      <tr><th>Bread</th><th>Price</th></tr>
      <tr><td>Rye</td><td>$5</td></tr>
      <tr><td>Sourdough</td><td>$6</td></tr>
    </table>
  • <caption>

    The title of a table. It goes right after the table tag.

    Attributes: only the global ones, like id, class and lang

    Example
    <table>
      <caption>Today's bread</caption>
      <tr><td>Rye</td><td>$5</td></tr>
    </table>
  • <thead>

    The header rows of a table.

    Attributes: only the global ones, like id, class and lang

    Example
    <table>
      <thead>
        <tr><th>Bread</th><th>Price</th></tr>
      </thead>
      <tbody>
        <tr><td>Rye</td><td>$5</td></tr>
      </tbody>
    </table>
  • <tbody>

    The main rows of a table. Browsers add one for you if you leave it out.

    Attributes: only the global ones, like id, class and lang

    Example
    <table>
      <tbody>
        <tr><td>Rye</td><td>$5</td></tr>
        <tr><td>Spelt</td><td>$7</td></tr>
      </tbody>
    </table>
  • <tfoot>

    The footer rows of a table, like a total.

    Attributes: only the global ones, like id, class and lang

    Example
    <table>
      <tbody>
        <tr><td>Rye</td><td>$5</td></tr>
        <tr><td>Cake</td><td>$12</td></tr>
      </tbody>
      <tfoot>
        <tr><th>Total</th><td>$17</td></tr>
      </tfoot>
    </table>
  • <tr>

    One row in a table.

    Attributes: only the global ones, like id, class and lang

    Example
    <table>
      <tr><td>One row</td><td>with two cells</td></tr>
    </table>
  • <th>

    A header cell. Shown bold and centered.

    Attributes: scope col or row, which cells it’s the header for colspan / rowspan stretch over several cells

    Example
    <table>
      <tr><th scope="col">Day</th><th scope="col">Open</th></tr>
      <tr><td>Monday</td><td>7 to 3</td></tr>
    </table>
  • <td>

    A normal cell with data.

    Attributes: colspan stretch over several columns rowspan stretch over several rows

    Example
    <table>
      <tr><td>Rye</td><td>$5</td></tr>
      <tr><td colspan="2">Sold out after 1 pm</td></tr>
    </table>
  • <colgroup>

    Groups table columns so you can style them together.

    Attributes: span how many columns it covers

    Example
    <table>
      <colgroup>
        <col>
        <col style="background: #ecfccb">
      </colgroup>
      <tr><th>Bread</th><th>Price</th></tr>
      <tr><td>Rye</td><td>$5</td></tr>
    </table>
  • <col>

    void · no closing tag

    One column inside a colgroup, mostly used to give it a width or background.

    Attributes: span how many columns it covers

    Example
    <table>
      <colgroup>
        <col span="2" style="background: #f3f4f6">
      </colgroup>
      <tr><td>Rye</td><td>$5</td></tr>
    </table>

Forms

Text boxes, buttons, drop-downs and the rest of what people fill in. In the results here, sending a form is switched off.

  • <form>

    Wraps form fields and sends what people typed when they submit it.

    Attributes: action where it’s sent method get or post novalidate skip the browser’s checks

    Example
    <form action="/subscribe" method="post">
      <label>Email <input type="email" name="email" required></label>
      <button type="submit">Subscribe</button>
    </form>
  • <label>

    The name of a form field. Clicking it puts the cursor in the field.

    Attributes: for the id of its field

    Example
    <label for="email">Email</label>
    <input id="email" type="email">
  • <input>

    void · no closing tag

    A form field. The type picks the kind: text, email, number, checkbox, radio, date and many more.

    Attributes: type the kind of field name the name sent with the form placeholder a hint shown while empty required must be filled in

    Example
    <input type="text" name="name" placeholder="Your name">
    <label><input type="checkbox" checked> Send me news</label>
    <input type="date">
  • <button>

    A button people can click. Inside a form it sends the form, unless you set type="button".

    Attributes: type submit, button or reset disabled can’t be clicked name / value sent with the form

    Example
    <button type="button">Click me</button>
  • <select>

    A drop-down list of choices.

    Attributes: name the name sent with the form multiple allow several choices required a choice is needed

    Example
    <select name="bread">
      <option>Rye</option>
      <option selected>Sourdough</option>
      <option>Baguette</option>
    </select>
  • <option>

    One choice in a select or a datalist.

    Attributes: value what’s sent, if it differs from the text selected chosen at the start disabled can’t be picked

    Example
    <select>
      <option value="rye">Rye</option>
      <option value="spelt" disabled>Spelt (sold out)</option>
    </select>
  • <optgroup>

    Groups options inside a select under a label.

    Attributes: label the group name

    Example
    <select>
      <optgroup label="Bread">
        <option>Rye</option>
        <option>Sourdough</option>
      </optgroup>
      <optgroup label="Cakes">
        <option>Carrot cake</option>
      </optgroup>
    </select>
  • <datalist>

    Suggestions for a text field. People can pick one or still type anything.

    Attributes: id the name the input’s list points to

    Example
    <input list="breads" placeholder="Pick a bread">
    <datalist id="breads">
      <option value="Rye"></option>
      <option value="Sourdough"></option>
    </datalist>
  • <selectedcontent>

    Shows a copy of the chosen option inside the button of a customizable select.

    Attributes: only the global ones, like id, class and lang

    New. So far only some browsers support it (Chrome and Edge first). Others show a normal drop-down, so it’s safe to use.

    Example
    <style>
      select, ::picker(select) { appearance: base-select; }
    </style>
    <select>
      <button><selectedcontent></selectedcontent></button>
      <option>🍞 Bread</option>
      <option>🥐 Croissant</option>
    </select>
  • <textarea>

    A text box for several lines of text, like a message.

    Attributes: name the name sent with the form rows / cols its size in lines and characters placeholder a hint shown while empty maxlength the most characters allowed

    Example
    <textarea name="message" rows="3" placeholder="Your message"></textarea>
  • <fieldset>

    Groups related fields, with a border around them.

    Attributes: disabled switch off every field inside

    Example
    <fieldset>
      <legend>Size</legend>
      <label><input type="radio" name="size" checked> Small</label>
      <label><input type="radio" name="size"> Large</label>
    </fieldset>
  • <legend>

    The caption of a fieldset, shown on its border.

    Attributes: only the global ones, like id, class and lang

    Example
    <fieldset>
      <legend>Extras</legend>
      <label><input type="checkbox"> Sliced</label>
    </fieldset>
  • <output>

    Shows the result of a calculation or of something the user did.

    Attributes: for the ids of the fields it uses name the name for scripts

    Example
    <p>2 + 3 = <output>5</output></p>
  • <progress>

    A progress bar, like for an upload. Leave out value for a "busy" bar.

    Attributes: value how far it is max the end value, 1 by default

    Example
    <progress value="70" max="100">70%</progress>
  • <meter>

    A gauge for a value in a known range, like disk space or a score.

    Attributes: value the current value min / max the range low / high / optimum which part of the range is good

    Example
    <meter value="0.6">60%</meter>

Interactive elements

Boxes that open and close, and pop-ups, built into HTML.

  • <details>

    A box that opens and closes when clicked. No JavaScript needed.

    Attributes: open start opened name give several the same name and only one stays open

    Example
    <details>
      <summary>Is the bread vegan?</summary>
      <p>Yes, all our loaves are.</p>
    </details>
  • <summary>

    The always-visible label of a details box. Clicking it opens the box.

    Attributes: only the global ones, like id, class and lang

    Example
    <details>
      <summary>Opening hours</summary>
      <p>Every day, 7 to 3.</p>
    </details>
  • <dialog>

    A dialog box or pop-up. Open it with the open attribute or from JavaScript with showModal().

    Attributes: open show it now, without a dark backdrop

    The OK button closes the dialog on your page. It does nothing in the result here, because results can’t run forms.

    Example
    <dialog open>
      <p>Your bread is in the cart.</p>
      <form method="dialog"><button>OK</button></form>
    </dialog>

Scripting & web components

JavaScript, drawing areas and the building blocks of web components. Scripts don’t run in this page’s results.

  • <script>

    JavaScript code, written in the page or loaded from a file.

    Attributes: src the .js file defer run after the page is read type module for modern imports async run as soon as it loads

    Example
    <script src="app.js" defer></script>
    <script>
      console.log('Hello!');
    </script>
  • <noscript>

    Content shown only when JavaScript is switched off.

    Attributes: only the global ones, like id, class and lang

    Example
    <noscript>
      <p>Please turn on JavaScript to see the map.</p>
    </noscript>
  • <canvas>

    A drawing area for JavaScript: charts, games, photo effects.

    Attributes: width / height the drawing size in pixels

    Example
    <canvas id="chart" width="300" height="150">
      A chart of this week's sales.
    </canvas>
  • <template>

    HTML that isn’t shown. JavaScript copies it into the page when needed.

    Attributes: shadowrootmode open makes a shadow root with no JavaScript

    Example
    <template id="row">
      <li class="item"></li>
    </template>
  • <slot>

    A placeholder inside a web component, filled with the content you give it.

    Attributes: name which content goes in it

    Example
    <div>
      <template shadowrootmode="open">
        <p>Hello, <slot name="user">friend</slot>!</p>
      </template>
      <b slot="user">Ana</b>
    </div>

Old tags you shouldn’t use

These were taken out of HTML. Some still work in browsers, but validators flag them and some do nothing at all now. Here’s what to write instead.

  • <center>

    obsolete

    Centered its content.

    Use instead: CSS text-align: center for text, or flexbox to center boxes.

    How to center text →

    Write this instead
    <p style="text-align: center">Centered text</p>
  • <font>

    obsolete

    Changed the size, color and typeface of text.

    Use instead: CSS color, font-size and font-family.

    Write this instead
    <span style="color: #b91c1c; font-size: 20px">Big red text</span>
  • <marquee>

    obsolete

    Scrolled text across the screen.

    Use instead: A CSS animation, if you really need movement. Moving text is hard to read, so most sites skip it.

    Write this instead
    <style>
      @keyframes slide { from { transform: translateX(100%); } to { transform: translateX(-100%); } }
      .news { overflow: hidden; }
      .news span { display: inline-block; animation: slide 10s linear infinite; }
    </style>
    <p class="news"><span>Fresh bread at 7!</span></p>
  • <big>

    obsolete

    Made text one size bigger.

    Use instead: CSS font-size, or a heading or strong if that’s what you mean.

    Write this instead
    <span style="font-size: larger">Bigger text</span>
  • <strike>

    obsolete

    Drew a line through text.

    Use instead: s for text that’s no longer right, or del for text removed in an edit.

    Write this instead
    <p><s>$8</s> $6</p>
  • <tt>

    obsolete

    Showed text in a typewriter (monospace) font.

    Use instead: code, kbd, samp or var, whichever fits, or CSS font-family: monospace.

    Write this instead
    <p>Run <code>npm install</code> first.</p>
  • <frameset>

    obsolete

    Split the browser window into several pages.

    Use instead: One page laid out with CSS, or an iframe where you really need a page inside a page.

    Write this instead
    <iframe src="menu.html" title="Menu"></iframe>
  • <frame>

    void · no closing tag obsolete

    One page inside a frameset.

    Use instead: iframe, or one page laid out with CSS.

    Write this instead
    <iframe src="menu.html" title="Menu"></iframe>
  • <noframes>

    obsolete

    Backup content for browsers without frames.

    Use instead: Nothing. Frames are gone, so there’s nothing to fall back from.

    Nothing to write instead.

  • <acronym>

    obsolete

    Marked an acronym, like NASA.

    Use instead: abbr, for every kind of abbreviation.

    Write this instead
    <abbr title="World Wide Web">WWW</abbr>
  • <applet>

    obsolete

    Ran a Java applet in the page.

    Use instead: Browsers don’t run Java any more. Rebuild it with JavaScript (for example on a canvas), or use embed or object for other files.

    Write this instead
    <canvas id="game" width="320" height="240"></canvas>
  • <basefont>

    void · no closing tag obsolete

    Set the default font for the page.

    Use instead: CSS on the body.

    Write this instead
    <style>
      body { font-family: Georgia, serif; font-size: 18px; }
    </style>
  • <dir>

    obsolete

    A list of files or folders.

    Use instead: ul.

    Write this instead
    <ul>
      <li>photos</li>
      <li>notes.txt</li>
    </ul>
  • <param>

    void · no closing tag obsolete

    Passed settings to an object.

    Use instead: Put the settings in the address in the object’s data attribute.

    Write this instead
    <object data="menu.pdf#page=2" type="application/pdf" width="400" height="300"></object>
  • <keygen>

    void · no closing tag obsolete

    Made a key pair for certificates when a form was sent.

    Use instead: The Web Crypto API in JavaScript (crypto.subtle.generateKey()).

    Nothing to write instead.

  • <menuitem>

    obsolete

    A command in a right-click menu. Only Firefox ever supported it.

    Use instead: A contextmenu event in JavaScript, or a plain menu of buttons.

    Write this instead
    <menu>
      <li><button>Copy</button></li>
    </menu>
  • <xmp>

    obsolete

    Showed code as typed, without reading the tags inside.

    Use instead: pre and code, with < written as &lt; and & as &amp;.

    Escape code with the Entity Encoder →

    Write this instead
    <pre><code>&lt;p&gt;Hello&lt;/p&gt;</code></pre>
  • <listing>

    obsolete

    Showed a code listing as typed.

    Use instead: pre and code.

    Write this instead
    <pre><code>let total = 0;</code></pre>
  • <plaintext>

    obsolete

    Showed the rest of the page as plain text.

    Use instead: Serve the file as plain text (a .txt file), or use pre for a part of a page.

    Write this instead
    <pre>Plain text here</pre>
  • <nobr>

    obsolete

    Stopped a line from breaking.

    Use instead: CSS white-space: nowrap, or &nbsp; between two words.

    Space entities like &nbsp; →

    Write this instead
    <span style="white-space: nowrap">Keep these words together</span>
  • <bgsound>

    void · no closing tag obsolete

    Played background sound in old Internet Explorer.

    Use instead: audio with controls, so people can stop it.

    Write this instead
    <audio src="song.mp3" controls></audio>
  • <spacer>

    obsolete

    Added empty space, in old Netscape.

    Use instead: CSS margin or padding.

    Write this instead
    <p style="margin-top: 24px">Text with space above</p>
  • <multicol>

    obsolete

    Laid text out in columns, in old Netscape.

    Use instead: CSS columns.

    Write this instead
    <div style="columns: 2">A long text that flows into two columns.</div>
  • <isindex>

    obsolete

    Added a one-line search box to the page.

    Use instead: A form with an input.

    Write this instead
    <form action="/search">
      <input type="search" name="q" aria-label="Search">
    </form>
  • <noembed>

    obsolete

    Backup content for embed.

    Use instead: object, with the backup content inside it.

    Write this instead
    <object data="menu.pdf" type="application/pdf">
      <a href="menu.pdf">Download the menu</a>
    </object>
  • <nextid>

    obsolete

    Helped very old editors make unique IDs.

    Use instead: Nothing. Pick your own id values.

    Nothing to write instead.

  • <rb>

    obsolete

    Marked the base text inside ruby.

    Use instead: Put the text straight inside ruby, followed by rt.

    Write this instead
    <ruby>漢<rt>kan</rt></ruby>
  • <rtc>

    obsolete

    Grouped several ruby text parts.

    Use instead: rt after each character, or nested ruby.

    Write this instead
    <ruby>漢<rt>kan</rt>字<rt>ji</rt></ruby>

What is an HTML tag?

A tag is a word in angle brackets that tells the browser what a piece of your page is. Most tags come in pairs: an opening tag, the content, and a closing tag with a slash. Extra settings go inside the opening tag as attributes, written name="value".

<a href="/menu">See the menu</a>
  • Opening tag <a>: starts the link
  • Attribute href="/menu": where it goes
  • Content: the text people click
  • Closing tag </a>: ends it

The whole thing, from <a> to </a>, is called an element. People mix up the two words all the time and that’s fine: the tag is the bit in brackets, the element is the tag plus what’s inside.

Tags go inside each other like boxes, and you close them in reverse order, inner one first: <p><strong>Hi</strong></p> is right, <p><strong>Hi</p></strong> is not. Browsers try to guess what you meant, but the guess isn’t always what you wanted. Our HTML Validator points out tags that are closed in the wrong order or not at all.

The basic HTML page skeleton

Every page starts with the same few tags. Copy this starter and change the title and the text:

starter.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My first page</title>
</head>
<body>
  <h1>Hello!</h1>
  <p>This is my first web page.</p>
</body>
</html>
  • <!doctype html> tells the browser this is modern HTML. It isn’t a tag, just a note at the very top.
  • <html lang="en"> wraps everything and says which language the page is in.
  • <head> holds details about the page: the character set, the phone-friendly viewport and the title in the tab.
  • <body> holds everything people see.

Paste it into our HTML Editor to try it right away, and add CSS and JavaScript in the other tabs.

Block vs inline elements

Most tags show in one of two ways. Block elements start on a new line and take the full width, like paragraphs and headings. Inline elements sit inside a line of text and are only as wide as their content, like links and bold words.

Block: <div> <p> <h2>

<div> one
<div> two
<p> three

Each one starts on a new line and stretches across.

Inline: <span> <a> <strong>

Text with <span> and <a> and <strong> flowing in the same line.

They stay in the line and are only as wide as their text.

Common block elements: div, p, h1–h6, ul, ol, li, table, form, header, footer, section, article, nav, blockquote, pre, hr.

Common inline elements: a, span, strong, em, b, i, code, br, small, mark, sub, sup, abbr, time. Images, inputs and buttons are inline too, but they have a width and height like a box (inline-block).

💡 This is only the starting point. CSS can change it: display: block makes a link take a full line, and display: inline puts list items side by side. The HTML standard itself now talks about “flow” and “phrasing” content instead, but block and inline is how most people think about it.

Self-closing tags (void elements)

A few tags can never have anything inside them, so they have no closing tag. HTML calls them void elements. There are 13 of them:

<area><base><br><col><embed><hr><img><input><link><meta><source><track><wbr>

You can write them as <br> or <br />; both work and mean the same thing. The slash is a habit from XHTML and is simply ignored in HTML. Never write </br> or <img></img>.

💡 The slash doesn’t make other tags self-closing. <div /> is read as an opening <div>, so everything after it ends up inside that div. Always write <div></div>. (Inside <svg> it’s different: SVG tags like <circle /> really can close themselves.)

Semantic tags: header, nav, main, article, section, aside, footer

Semantic tags say what a part of the page is, not how it looks. On screen, <nav> looks exactly like a <div>. The difference is for everything that reads your code:

  • Screen readers list most of them (header, nav, main, aside, footer) as landmarks, so people can jump straight to the menu or the main content.
  • Search engines get a better idea of which part is the actual article and which part is the menu or footer.
  • You and your team can read <footer> faster than <div class="ft-wrap">.
A typical page outline
<body>
  <header>Logo and site name</header>
  <nav>Home · Menu · Contact</nav>
  <main>
    <article>
      <h1>How we bake sourdough</h1>
      <section>…</section>
    </article>
    <aside>Related posts</aside>
  </main>
  <footer>&copy; 2026 Pixel Bakery</footer>
</body>

Use <div> and <span> when no other tag fits: they’re perfect for boxes that are only there for styling. Many of these tags came with HTML5, which is why people search for “HTML5 tags”. Others from that time are figure, mark, time, video, audio, canvas, details and progress.

The HTML tags people look for most

You want Write Looks like
A link <a href="https://example.com">Example</a> Example
An image <img src="cat.jpg" alt="My cat"> Sample picture
A line break Line one<br>Line two Line one
Line two
Bold text <strong>Important</strong> or <b>keyword</b> Important or keyword
Italic text <em>really</em> or <i>voilà</i> really or voilà
Underline <u>spel</u> (or CSS) spel
Strikethrough <s>$8</s> or <del>old</del> $8 or old
A new paragraph <p>Some text.</p> A block with space around it
A bulleted list <ul><li>Milk</li></ul>
  • Milk
A comment <!-- note to self --> Nothing: comments never show
Extra spaces &nbsp; See HTML entities
Centered text style="text-align: center" See how to center text
A table <table>, <tr>, <td> Build one in the Table Generator

Bold vs strong, italic vs em. They look the same, but they mean different things. Use <strong> for text that matters (“Don’t unplug the oven”) and <em> for stress that changes the meaning (“I said rye”). Use <b> and <i> when you only want the look for a reason, like a product name or a foreign word. The meaning is in the code for search engines and other tools that read it, even when it looks the same. If you only want a style, say bold headings in a menu, CSS font-weight: bold is the cleanest.

Old tags and what to use instead

Some tags were taken out of HTML years ago. A few still work, but they mix up content and looks, and validators flag them. The old tags list above has all of them; here are the ones people still run into:

Old tagUse instead
<center>CSS text-align: center, or flexbox (how to center)
<font>CSS color, font-size and font-family
<big>CSS font-size
<strike><s> or <del>
<tt><code>, <kbd> or <samp>
<marquee>, <blink>Usually nothing: moving and flashing text is hard to read
<frameset>, <frame>One page with CSS layout, or an <iframe>
<acronym><abbr>

💡 <b>, <i>, <u>, <s> and <small> are not deprecated, even though many old tutorials say so. HTML5 kept them and gave each one a clear job.

Check your tags

Paste your page into the HTML Validator to find tags that aren’t closed, attributes with typos and old tags. To show a tag as text on a page (like this page does), write < as &lt;; the HTML entities list has the rest.

Frequently Asked Questions

How many HTML tags are there?

The current HTML standard has 113 elements, plus svg and math, which come from SVG and MathML and can be written right inside HTML. That counts h1 to h6 as six. On top of that there are about 30 old tags, like center and font, that were taken out of HTML. You only need a couple of dozen for most pages.

What are the basic HTML tags every page needs?

Every page starts with <!doctype html>, then <html lang="en"> around everything, a <head> with <meta charset="utf-8">, the viewport meta tag and a <title>, and a <body> for what people see. Inside the body, the tags you’ll use most are h1 to h6 for headings, p for paragraphs, a for links, img for images, ul or ol with li for lists, and div and span for grouping.

What is the HTML tag for a line break?

It’s <br>, for example Line one<br>Line two. It has no closing tag. Pressing Enter in your code doesn’t start a new line on the page, because browsers treat line breaks in the code like spaces. For space between paragraphs, wrap each one in <p> instead of adding several <br> tags.

What’s the difference between <b> and <strong>, or <i> and <em>?

They look the same but mean different things. <strong> marks text that’s important and <em> marks stress, the word you’d say louder. <b> and <i> only set words apart, like a keyword, a product name or a foreign word, without making them more important. The meaning is in the code for any tool that reads it, even though most screen readers don’t change their voice for it. If you only want the look, CSS font-weight: bold or font-style: italic works too.

What are self-closing tags in HTML?

They’re called void elements: tags that can never have content, so they have no closing tag. There are 13: area, base, br, col, embed, hr, img, input, link, meta, source, track and wbr. You can write <br> or <br />, both are fine. The slash doesn’t make other tags self-closing, though: <div /> is read as an opening <div>, so always write <div></div>.

What’s the difference between block and inline elements?

Block elements, like div, p, h1 and ul, start on a new line and take the full width. Inline elements, like a, span, strong and em, sit inside a line of text and are only as wide as their content. You can’t give an inline element a width or a top margin until you change it with CSS, for example display: block or display: inline-block.

Are <center>, <font> and <marquee> still allowed?

No. They were taken out of HTML and validators report them as errors. Browsers still show some of them so old pages don’t break, but don’t use them in new code. Use CSS text-align: center instead of <center>, and CSS color, font-size and font-family instead of <font>. The old tags list on this page has what to use for each one.

Which tags came with HTML5?

HTML5 added the semantic tags header, nav, main, article, section, aside and footer, plus figure, figcaption, mark, time, video, audio, source, track, canvas, details, summary, progress, meter, output and datalist. Newer ones followed later, like picture, dialog and search. It also kept b, i, u, s and small and gave them new meanings, so they aren’t deprecated.

Are HTML tags case-sensitive?

No. <P>, <p> and <P CLASS="x"> all work the same. Lowercase is the usual style and it’s what every example here uses. Even SVG names like viewBox work in any case in an HTML file, because the browser fixes them for you. Case only matters in XML files, or when you create SVG from JavaScript.