Tag in HTML: What It Is, Syntax Rules and Tag List

November 11, 2026 · 14 min read

What Is a Tag in HTML? Elements, Attributes and an HTML Tag List

A tag in HTML is the markup inside angle brackets that marks where an element starts or ends. <p> opens a paragraph and </p> closes it. Browsers read tags to build the page but never display them. Below you'll find the exact anatomy, the syntax rules that trip people up, and a grouped HTML tag list.

What Are Angle Brackets in HTML Tags?

Angle brackets are the < and > characters that wrap every tag. Whatever sits between them is an instruction for the browser, not text for the reader. HTML is a markup language, a family our Markdown vs markup explainer covers in more depth.

A start tag is the element's name in angle brackets. An end tag adds a forward slash before the name. It's a forward slash, not a backslash, whatever some tutorials say.

<p>Hello, world</p>

The browser shows only Hello, world as a paragraph of text. The <p> and </p> vanish from the visible page, though they stay in the source and the DOM holds the p element they create. To show a literal angle bracket as text, write the character reference &lt; for < and &gt; for >.

Tag in HTML, Element or Attribute: What's the Difference?

People use "tag" loosely, but the spec separates three ideas. Tags are the markup. An element is the whole thing the tags create, including its content. Attributes are extra settings written inside the start tag.

<abbr title="HyperText Markup Language" class="term">HTML</abbr>

Here's how that line breaks down:

  • <abbr title="HyperText Markup Language" class="term"> is the start tag.
  • title and class are attribute names, and the quoted text after each = is the attribute value.
  • HTML is the element's content, the only part the reader sees.
  • </abbr> is the end tag.
  • The start tag, content and end tag together make one abbr element.

This is why "alt tag" is a misnomer. alt is an attribute on the img element, not a tag of its own. The same goes for "title tag" when someone means the title attribute, which differs from the <title> element in the page head.

Tags With No Closing Tag: The 13 Void Elements

Most elements take two tags, a start tag and an end tag. Void elements can't hold content, so they get a start tag only. The WHATWG HTML syntax section lists exactly 13 of them.

The void elements are area, base, br, col, embed, hr, img, input, link, meta, source, track and wbr.

<p>Line one<br>Line two</p>
<img src="cat.jpg" alt="A grey cat asleep on a keyboard">
<input type="email" name="email" required>

That renders a paragraph split over two lines, an image (or its alt text if cat.jpg is missing) and an email field. Writing </br> or </img> is an error. Void elements have no content, so there's nothing for an end tag to close.

What about <br />? In HTML the trailing slash on a void element is allowed, but the spec says it's unnecessary and has no effect of any kind. It's a habit carried over from XHTML. JSX and MDX are stricter and reject an unclosed void element, so you must write <br /> there.

We prefer leaving the slash off in plain .html files and keeping it wherever JSX demands it. One more trap the spec warns about: a slash straight after an unquoted value joins the value. <img src=cat.jpg/> asks for a file called cat.jpg/.

How Attributes Work Inside the Start Tag

An attribute is a name="value" pair written inside the start tag, after the element name. It's how a tag in HTML carries settings like a link's destination or an image's source. You can add several, separated by spaces, in any order. Attributes never go in the end tag.

Quotes are optional for simple values, so class=nav is valid. They become required as soon as a value contains a space, a quote, =, <, > or a backtick. Quoting every value is the safer habit.

Boolean attributes such as disabled, checked and required work by presence alone. Writing required is enough. The catch: disabled="false" still disables the field, because the browser only checks whether the attribute exists.

Some attributes fit only certain elements, like href on links or src on images. Others are global and work on any element. The MDN global attributes reference lists them all. The ones you'll use most are id, class, style, title, lang, hidden and custom data-* attributes.

Nesting, Case and Optional End Tags: The Rules Browsers Apply

Elements nest like boxes, so you close tags in the reverse order you opened them. The first line below is correct. The second overlaps the tags, which is an error the browser has to guess its way out of.

<p>This is <strong>important</strong> text.</p>
<p>This is <strong>broken</p></strong>

Tag names are case-insensitive in HTML syntax, so <P>, <p> and <Div> all work. Write them in lowercase anyway, since that's what every style guide and tool expects. Attribute values are a different story: class names such as Nav and nav are not the same.

Some end tags are optional. The spec lets you omit the end tag of li, dt, dd, option, table rows and cells, and p in many cases. That last one causes a classic surprise:

<p>Intro text
  <div>A block inside a paragraph?</div>
</p>

This doesn't nest the way it looks. A p element closes automatically when a div, ul or heading starts. The browser ends the paragraph before the div, and the stray </p> creates a second, empty paragraph.

Browsers recover from mistakes like these instead of refusing to render, which hides them from you. Our HTML formatter re-indents your markup so nesting mistakes stand out and runs a basic issue check. It isn't a validator, so for a full conformance check use the W3C's Nu Html Checker.

Which Tag Is Used for HTML? The Skeleton Every Page Starts With

The <html> tag wraps the whole document. Inside it, <head> holds information about the page and <body> holds everything the reader sees. A minimal, valid page looks like this:

<!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 paragraph is visible on the page.</p>
  </body>
</html>
  • <!DOCTYPE html> isn't a tag or an element. It's a required preamble that keeps browsers in standards mode instead of an older rendering mode.
  • <html lang="en"> is the root element. The lang attribute tells screen readers and translators the page language.
  • <meta charset="utf-8"> sets the character encoding, and the viewport meta makes the page scale on phones.
  • <title> sets the page title shown in the browser tab, which search engines often use too.
  • <body> contains the visible content: here, one heading and one paragraph.

The spec technically lets you omit the html, head and body tags, and the browser creates those elements anyway. Keep them. Every tutorial, template and tool assumes they're there.

HTML Tag List: Common Tags Grouped by What They Do

This HTML tag list covers the tags you'll reach for on almost every page, grouped by job. In the End tag column, "Optional" means the spec lets you leave it out, and "None" marks a void element.

Document and metadata tags

TagWhat it doesEnd tag
<html>Root element that wraps the pageOptional
<head>Holds metadata, title, styles and scriptsOptional
<title>The page title shown in the browser tabYes
<meta>Adds metadata such as charset and viewportNone
<link>Connects an external resource, usually a stylesheetNone
<style>Holds CSS written inside the pageYes
<base>Sets the base URL for relative linksNone
<body>Contains all the visible contentOptional

Page section tags

TagWhat it doesEnd tag
<header>Intro content for a page or sectionYes
<nav>A block of main navigation linksYes
<main>The dominant content of the pageYes
<article>A self-contained piece, such as a post or commentYes
<section>A thematic group, normally with a headingYes
<aside>Side content, such as a sidebar or calloutYes
<footer>Closing info for a page or sectionYes

Heading tags h1 to h6

<h1> through <h6> are six heading levels, and each needs an end tag. Use h1 for the page title, h2 for main sections and h3 for subsections inside them. Don't skip levels, and don't pick a heading for its size, because CSS handles size. Several h1 elements are valid HTML, but MDN's guidance on heading elements advises one per page.

Text tags

TagWhat it doesEnd tag
<p>A paragraphOptional
<br>A line break inside textNone
<hr>A thematic break, drawn as a horizontal lineNone
<strong>Strong importance, bold by defaultYes
<em>Stress emphasis, italic by defaultYes
<b>Draws attention without adding importanceYes
<i>Set-apart text such as terms or foreign wordsYes
<mark>Highlighted textYes
<small>Side comments and fine printYes
<sub> and <sup>Subscript and superscriptYes
<code>Inline computer codeYes
<pre>Preformatted text that keeps its spacingYes
<kbd>Keyboard input, such as a shortcutYes
<blockquote>A long quotation from another sourceYes
<q>A short inline quotationYes
<abbr>An abbreviation or acronymYes
<span>Generic inline container with no meaningYes
<div>Generic block container with no meaningYes

List tags

TagWhat it doesEnd tag
<ul>Unordered, bulleted listYes
<ol>Ordered, numbered listYes
<li>One item in either listOptional
<dl>Description list of terms and detailsYes
<dt>A term in a description listOptional
<dd>The description for a termOptional

Link and media tags

TagWhat it doesEnd tag
<a>A hyperlink, with href as the destinationYes
<img>Embeds an image, with alt textNone
<picture>Offers different image sources per screenYes
<source>One media source inside picture, video or audioNone
<video>Embeds a video playerYes
<audio>Embeds an audio playerYes
<iframe>Embeds another web pageYes
<figure>Self-contained content, such as an image or chartYes
<figcaption>The caption for a figureYes

Table tags

TagWhat it doesEnd tag
<table>Wraps the whole tableYes
<caption>The table's titleOptional
<thead>Groups the header rowsOptional
<tbody>Groups the body rowsOptional
<tr>One table rowOptional
<th>A header cellOptional
<td>A data cellOptional

Form tags

TagWhat it doesEnd tag
<form>Collects input and submits itYes
<label>Names a form controlYes
<input>One field: text, checkbox, date and moreNone
<textarea>Multi-line text boxYes
<select>A drop-down listYes
<option>One choice inside a selectOptional
<button>A clickable buttonYes
<fieldset>Groups related controlsYes

Scripting tags

TagWhat it doesEnd tag
<script>Runs or loads JavaScriptYes
<noscript>Fallback content when scripts are offYes
<template>Markup that isn't shown until a script uses itYes

That's the working set, not the whole language. The MDN HTML elements reference lists every element, including rarer ones like details, dialog and output.

Obsolete HTML Tags and What Replaced Them

Old tutorials still teach tags that the current standard has dropped. The WHATWG list of obsolete features says authors must not use them. Browsers still render several, such as center and marquee, so old pages don't break, but a page using them doesn't conform.

Obsolete tagUse instead
<font>CSS color, font-family and font-size
<center>CSS text-align: center
<big>CSS, or <strong>, <mark> or a heading by meaning
<tt><code>, <kbd>, <samp> or <var>
<strike><del> for edits, <s> for anything else
<acronym><abbr>
<dir><ul>
<marquee> and <blink>CSS animation, used sparingly
<frame> and <frameset><iframe> and CSS

If you searched for the font tag, the fix is a stylesheet. Put color and font-family in a CSS rule and apply it with a class attribute.

How Markdown Marks Turn Into HTML Tags

Markdown is shorthand for a small set of HTML tags. When the file is converted, # becomes an h1, ** becomes strong, and a [text](url) link becomes an a element. Our guide on how to convert Markdown to HTML covers the full mapping and the conversion methods. For when to write which, see Markdown vs HTML.

The note below mixes Markdown with raw kbd and sub tags. Click Export HTML to see the tags each line produces.

Shopping list

A short note with emphasis.

  • Apples
  • Bread

Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy. Water is H<sub>2</sub>O.

Open the full editor

25 words173 characters10 lines
Markdown

The output contains h1, p, strong, em, ul, li, kbd, sub and a tags, wrapped in a full HTML document. The preview renders some raw HTML too, such as <kbd>, <sub>, <sup> and <details>. It strips scripts and event handlers, though, so it can't test HTML that relies on JavaScript.

A tag in HTML is only the marker: the element is what it builds, and attributes ride inside the start tag. Remember the 13 void elements, close tags in reverse order, and most markup bugs never happen. Paste messy markup into the HTML formatter to re-indent it, or write Markdown in the editor and let it produce the tags for you.