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.
Most searched
115 tags, plus 29 old ones
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:
langthe page language, like enExample<!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> -
void · no closing tag<meta>Page details for browsers and search engines: the character set, the viewport, the description.
Attributes:
charsetthe text encoding, always utf-8 ·namewhich detail, like description ·contentits value ·http-equivacts 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."> -
void · no closing tag<link>Connects the page to another file, like a stylesheet or the little icon in the tab.
Attributes:
relwhat kind of file, like stylesheet or icon ·hrefthe file address ·mediaonly for some screensExample<link rel="stylesheet" href="style.css"> <link rel="icon" href="favicon.svg" type="image/svg+xml"> -
<style>CSS written right inside the page.
Attributes:
mediaonly for some screens, like printExample<style> h1 { color: #4d7c0f; } </style> -
void · no closing tag<base>Sets the starting address for every relative link on the page. You rarely need it.
Attributes:
hrefthe base address ·targetwhere links open by defaultExample<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-labela name, when a page has more than one navExample<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> -
<footer>The bottom of a page or section: copyright, contact links, small print.
Attributes: only the global ones, like id, class and lang
Example<footer> <p>© 2026 Pixel Bakery</p> </footer> -
<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> -
<search>Wraps a search form or a set of filters, so assistive tech knows what it is.
Attributes: only the global ones, like id, class and lang
Added to HTML in 2023 and works in current browsers. Older ones treat it like a plain div, which is fine.
Example<search> <form action="/search"> <input type="search" name="q" aria-label="Search"> <button>Search</button> </form> </search>
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:
classa name for your CSS ·ida unique nameExample<div class="card"> <h3>Sourdough</h3> <p>$6</p> </div> -
void · no closing tag<hr>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:
citethe address of the sourceExample<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:
startthe first number ·reversedcount down ·type1, a, A, i or IExample<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:
valueits number, inside an olExample<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:
hrefwhere the link goes ·target_blank opens a new tab ·rellike noopener or nofollow ·downloadsave the file instead of opening itExample<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:
langthe language of a foreign wordExample<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:
classa name for your CSS ·styleCSS right on the tagExample<p>Our <span style="color: #4d7c0f">green</span> logo</p> -
void · no closing tag<br>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.
ExamplePixel Bakery<br> 12 Baker Street<br> Springfield -
void · no closing tag<wbr>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><br></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:
titlethe full wordsExample<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:
citethe address of the sourceExample<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:
datetimethe date as 2026-12-01 or a time as 14:30Example<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:
valuethe machine-readable valueExample<p>Best seller: <data value="SKU-1042">Rye loaf</data></p> -
<ins>Text that was added in an edit. Usually underlined.
Attributes:
datetimewhen it changed ·citea page that explains whyExample<p>Open until <del>2 pm</del> <ins>3 pm</ins></p> -
<del>Text that was removed in an edit. Shown struck through.
Attributes:
datetimewhen it changed ·citea page that explains whyExample<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:
dirltr 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.
-
void · no closing tag<img>Shows an image.
Attributes:
srcthe image file ·altwhat the image shows, for people who can’t see it ·width / heightstop the page jumping while it loads ·loadinglazy waits until it’s near the screenExample<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> -
void · no closing tag<source>One file option inside picture, video or audio. The browser picks the first one it can use.
Attributes:
srcthe file, in video and audio ·srcsetthe image file, in picture ·typethe file type ·mediaonly for some screensExample<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:
srcthe video file ·controlsshow play, pause and volume ·postera picture before it starts ·muted / loop / autoplayautoplay usually needs mutedExample<video src="clip.mp4" controls width="320" poster="poster.jpg"></video> -
<audio>Plays sound, like music or a podcast.
Attributes:
srcthe sound file ·controlsshow the player ·loopplay again at the endExample<audio src="song.mp3" controls></audio> -
void · no closing tag<track>Subtitles or captions for a video.
Attributes:
srcthe .vtt file ·kindsubtitles, captions and more ·srclangthe language, like en ·labelthe name in the menuExample<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:
namethe name usemap points toExample<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> -
void · no closing tag<area>One clickable area in an image map.
Attributes:
shaperect, circle or poly ·coordswhere it is ·hrefwhere it goes ·altthe link textExample<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:
srcthe page address ·titlewhat it is, for screen readers ·width / heightits size ·loadinglazy waits until it’s near the screenExample<iframe src="https://example.com" title="Example site" width="400" height="200"></iframe> -
void · no closing tag<embed>Puts an outside file, like a PDF, on the page with the browser’s own viewer.
Attributes:
srcthe file ·typethe file type ·width / heightits sizeExample<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:
datathe file ·typethe file type ·width / heightits sizeExample<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:
viewBoxthe drawing’s own coordinates ·width / heightits size on the pageExample<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:
displayblock puts the formula on its own lineExample<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
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:
scopecol or row, which cells it’s the header for ·colspan / rowspanstretch over several cellsExample<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:
colspanstretch over several columns ·rowspanstretch over several rowsExample<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:
spanhow many columns it coversExample<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> -
void · no closing tag<col>One column inside a colgroup, mostly used to give it a width or background.
Attributes:
spanhow many columns it coversExample<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:
actionwhere it’s sent ·methodget or post ·novalidateskip the browser’s checksExample<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:
forthe id of its fieldExample<label for="email">Email</label> <input id="email" type="email"> -
void · no closing tag<input>A form field. The type picks the kind: text, email, number, checkbox, radio, date and many more.
Attributes:
typethe kind of field ·namethe name sent with the form ·placeholdera hint shown while empty ·requiredmust be filled inExample<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:
typesubmit, button or reset ·disabledcan’t be clicked ·name / valuesent with the formExample<button type="button">Click me</button> -
<select>A drop-down list of choices.
Attributes:
namethe name sent with the form ·multipleallow several choices ·requireda choice is neededExample<select name="bread"> <option>Rye</option> <option selected>Sourdough</option> <option>Baguette</option> </select> -
<option>One choice in a select or a datalist.
Attributes:
valuewhat’s sent, if it differs from the text ·selectedchosen at the start ·disabledcan’t be pickedExample<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:
labelthe group nameExample<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:
idthe name the input’s list points toExample<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:
namethe name sent with the form ·rows / colsits size in lines and characters ·placeholdera hint shown while empty ·maxlengththe most characters allowedExample<textarea name="message" rows="3" placeholder="Your message"></textarea> -
<fieldset>Groups related fields, with a border around them.
Attributes:
disabledswitch off every field insideExample<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:
forthe ids of the fields it uses ·namethe name for scriptsExample<p>2 + 3 = <output>5</output></p> -
<progress>A progress bar, like for an upload. Leave out value for a "busy" bar.
Attributes:
valuehow far it is ·maxthe end value, 1 by defaultExample<progress value="70" max="100">70%</progress> -
<meter>A gauge for a value in a known range, like disk space or a score.
Attributes:
valuethe current value ·min / maxthe range ·low / high / optimumwhich part of the range is goodExample<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:
openstart opened ·namegive several the same name and only one stays openExample<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:
openshow it now, without a dark backdropThe 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:
srcthe .js file ·deferrun after the page is read ·typemodule for modern imports ·asyncrun as soon as it loadsExample<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 / heightthe drawing size in pixelsExample<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:
shadowrootmodeopen makes a shadow root with no JavaScriptExample<template id="row"> <li class="item"></li> </template> -
<slot>A placeholder inside a web component, filled with the content you give it.
Attributes:
namewhich content goes in itExample<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.
-
obsolete<center>Centered its content.
Use instead: CSS
text-align: centerfor text, or flexbox to center boxes.Write this instead<p style="text-align: center">Centered text</p> -
obsolete<font>Changed the size, color and typeface of text.
Use instead: CSS
color,font-sizeandfont-family.Write this instead<span style="color: #b91c1c; font-size: 20px">Big red text</span> -
obsolete<marquee>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> -
obsolete<big>Made text one size bigger.
Use instead: CSS
font-size, or a heading orstrongif that’s what you mean.Write this instead<span style="font-size: larger">Bigger text</span> -
obsolete<strike>Drew a line through text.
Use instead:
sfor text that’s no longer right, ordelfor text removed in an edit.Write this instead<p><s>$8</s> $6</p> -
obsolete<tt>Showed text in a typewriter (monospace) font.
Use instead:
code,kbd,samporvar, whichever fits, or CSSfont-family: monospace.Write this instead<p>Run <code>npm install</code> first.</p> -
obsolete<blink>Made text flash on and off.
Use instead: Nothing that flashes. To draw attention, use
strongormark.Write this instead<p><strong>Sale ends today</strong></p> -
obsolete<frameset>Split the browser window into several pages.
Use instead: One page laid out with CSS, or an
iframewhere you really need a page inside a page.Write this instead<iframe src="menu.html" title="Menu"></iframe> -
void · no closing tag obsolete<frame>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> -
obsolete<noframes>Backup content for browsers without frames.
Use instead: Nothing. Frames are gone, so there’s nothing to fall back from.
Nothing to write instead.
-
obsolete<acronym>Marked an acronym, like NASA.
Use instead:
abbr, for every kind of abbreviation.Write this instead<abbr title="World Wide Web">WWW</abbr> -
obsolete<applet>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 useembedorobjectfor other files.Write this instead<canvas id="game" width="320" height="240"></canvas> -
void · no closing tag obsolete<basefont>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> -
obsolete<dir>A list of files or folders.
Use instead:
ul.Write this instead<ul> <li>photos</li> <li>notes.txt</li> </ul> -
void · no closing tag obsolete<param>Passed settings to an object.
Use instead: Put the settings in the address in the object’s
dataattribute.Write this instead<object data="menu.pdf#page=2" type="application/pdf" width="400" height="300"></object> -
void · no closing tag obsolete<keygen>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.
-
obsolete<menuitem>A command in a right-click menu. Only Firefox ever supported it.
Use instead: A
contextmenuevent in JavaScript, or a plainmenuof buttons.Write this instead<menu> <li><button>Copy</button></li> </menu> -
obsolete<xmp>Showed code as typed, without reading the tags inside.
Use instead:
preandcode, with<written as<and&as&.Write this instead<pre><code><p>Hello</p></code></pre> -
obsolete<listing>Showed a code listing as typed.
Use instead:
preandcode.Write this instead<pre><code>let total = 0;</code></pre> -
obsolete<plaintext>Showed the rest of the page as plain text.
Use instead: Serve the file as plain text (a .txt file), or use
prefor a part of a page.Write this instead<pre>Plain text here</pre> -
obsolete<nobr>Stopped a line from breaking.
Use instead: CSS
white-space: nowrap, or between two words.Write this instead<span style="white-space: nowrap">Keep these words together</span> -
void · no closing tag obsolete<bgsound>Played background sound in old Internet Explorer.
Use instead:
audiowithcontrols, so people can stop it.Write this instead<audio src="song.mp3" controls></audio> -
obsolete<spacer>Added empty space, in old Netscape.
Use instead: CSS
marginorpadding.Write this instead<p style="margin-top: 24px">Text with space above</p> -
obsolete<multicol>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> -
obsolete<isindex>Added a one-line search box to the page.
Use instead: A
formwith aninput.Write this instead<form action="/search"> <input type="search" name="q" aria-label="Search"> </form> -
obsolete<noembed>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> -
obsolete<nextid>Helped very old editors make unique IDs.
Use instead: Nothing. Pick your own
idvalues.Nothing to write instead.
-
obsolete<rb>Marked the base text inside ruby.
Use instead: Put the text straight inside
ruby, followed byrt.Write this instead<ruby>漢<rt>kan</rt></ruby> -
obsolete<rtc>Grouped several ruby text parts.
Use instead:
rtafter each character, or nestedruby.Write this instead<ruby>漢<rt>kan</rt>字<rt>ji</rt></ruby>
No tags match that search. Try a shorter word, like “list”, “image” or “form”.
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:
<!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>
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">.
<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>© 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"> | |
| 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> | |
| A new paragraph | <p>Some text.</p> | A block with space around it |
| A bulleted list | <ul><li>Milk</li></ul> |
|
| A comment | <!-- note to self --> | Nothing: comments never show |
| Extra spaces | | 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 tag | Use 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
<; 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.