References

Beginner-friendly references for web development, with live, editable examples.

The HTML <h5> tag

Element All modern browsers
In short

The HTML <h5> element is a fifth-level heading, the next step down from <h4>. Use it inside an h4 section, as in <h5>Hinges</h5> under an h4 called Doors. At 0.83em by default, about 13.28px next to 16px text, it is smaller than the text around it.

Overview

The HTML <h5> element is the fifth heading level, the first one smaller than body text by default. It belongs inside an <h4> section in documents with at least five layers of headings, such as a long manual or a technical specification, and only <h6> ranks below it.

An h5 can follow an h4, another h5 or an h6, but not an h3, h2 or h1. An h3 directly before an h5 would leave level 4 empty.

An h5's 0.83em default is about 13.28px beside 16px text, with 1.67em margins. Bold weight keeps it readable as a heading at that size.

The size is relative to the parent element, not fixed. Inside a box whose text is 20px, the same h5 grows to about 16.6px. A size set in rem or px instead makes every h5 on a site look the same, wherever it sits.

Syntax

<h4>Doors</h4>
<h5>Hinges</h5>
<p>Each door hangs on three steel hinges.</p>

Example

Live example
<label for="size">Parent text size</label>
<input type="range" id="size" min="12" max="24" value="16">
<p id="out"></p>
<div id="box">
  <h4>Doors</h4>
  <h5>Hinges</h5>
  <p>Each door hangs on three steel hinges.</p>
</div>
<script>
const box = document.getElementById('box');
const size = document.getElementById('size');
function show() {
  box.style.fontSize = size.value + 'px';
  const h5 = getComputedStyle(box.querySelector('h5')).fontSize;
  document.getElementById('out').textContent = 'Parent ' + size.value + 'px, h5 ' + h5;
}
size.addEventListener('input', show);
show();
</script>

Best practices

  • Put an h4 above every h5.
  • Size h5 in CSS when it shouldn't look smaller than your body text.
  • Set that size in rem rather than em when every h5 should match, since an em size follows each parent's font size.
  • Avoid choosing h5 because its small bold text matches a design. Style a paragraph instead when the text isn't a heading, and keep <strong> for text of strong importance, seriousness or urgency.

Accessibility

An h5 used for a small bold label puts a false entry in the page's list of headings. Most screen readers can generate that list, and anyone scanning it then finds labels mixed in with real section titles.

Frequently asked questions

What does h5 mean in HTML?
In HTML, h5 means a fifth-level heading, the level under h4. Only the h6 tag sits below it.
What size is an h5 in px?
An h5 is about 13.28px when its parent's text is 16px, because its default font size is 0.83em. The exact pixel size follows the parent's font size.
Should a subtitle be marked up as an h5?
No, an h5 adds its own entry to the outline, so a subtitle belongs in a p inside hgroup. The hgroup element groups a heading with p elements for a subheading, alternative title or tagline.
When should I use an h5?
Use an h5 for the next layer down inside an h4 section in a deeply nested document. A page whose sections stop at h4 has no need for it.
Can I make an h5 bigger than an h4?
Yes, CSS can give an h5 any size, even one larger than an h4. Its level stays 5, so it still follows its h4 when the page's headings are listed in order.