STR-002a Mark text that heads a part of the view as a heading in code
- Level
- Rule
- Verdict
- Requirement
- Area
- Page structure
- Status
- proposed, version 1.0.0
Rule
When text heads a part of the view, such as a section, a card, a panel or a dialog, mark it as a heading in code, not only with bold or large type.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: Section titles are headings
Page: Project settings
h1Project settingsh2MembersMaya Lindqvist, Tomas Reyes and 2 more
h2Billing address14 Alder Lane, Bristol
h2Delete projectThis cannot be undone.
Simulated: the heading list a screen reader would build from this page's code:
h1Project settingsh2Membersh2Billing addressh2Delete project
h1 and each section. The chips show every title is a heading element, styled with classes to look as it does.Don't: Styled text, not headings
Page: Project settings
pProject settingsdivMembersMaya Lindqvist, Tomas Reyes and 2 more
divBilling address14 Alder Lane, Bristol
divDelete projectThis cannot be undone.
Simulated: the heading list a screen reader would build from this page's code:
No headings. A person who lists headings finds nothing.
p and div with bold type. The heading list is empty and Next heading has nowhere to go: to a screen reader the page has no sections.Don't: A price marked as a heading
Page: Plans
h1Choose a planh2Teamh3€12 a monthUp to 10 members
Simulated: the heading list a screen reader would build from this page's code:
h1Choose a planh2Teamh3€12 a month
h3 too so that it stands out. A price heads nothing, and the heading list now offers it as a section.Why
A sighted person finds their way down a page by the titles that stand out. A screen reader user does the same with a list of headings and a key that jumps from one to the next. That only works when the titles are headings in code. Text styled to look like a heading is, to a screen reader, one more line of text, so the page has no sections to jump between. The reverse misleads just as much: heading markup on a label or a number invents a section that is not there.
This is a requirement. WCAG 2.2, 1.3.1 Info and Relationships asks that structure shown on screen can also be read from the code. The Working Group lists as a failure text that is styled to look like a heading but is marked up as ordinary text (F2), and its HTML technique is the h1 to h6 elements (H42). The same criterion fails heading markup on text that heads nothing (F43). The criterion does not ask that a page have headings, or a certain number of them. It asks that what works as a heading is one. What the heading says is STR-002b, and its level is STR-003.
Do
- In the project tool Ridgeway, the page Project settings has the sections Members, Billing address and Delete project. Each section title is a heading element, styled with classes.
- In shadcn,
CardTitleandAlertTitlerender adivand take noasChild. When the title heads what is in the card or the alert, put anh2orh3inside it, or change the element the component renders. SidebarGroupLabelalso renders adiv, but takesasChild. When it heads a group of links, write<SidebarGroupLabel asChild><h2>Projects</h2></SidebarGroupLabel>, which keeps its styling.- Keep
DialogTitle,SheetTitle,AlertDialogTitleandDrawerTitle. They render headings through Radix and also give the dialog its name. - When a heading takes focus from script, as DLG-006 allows in one case, it stays a heading element with
tabindex="-1". - Our own advice, not required: when a part is plain to sighted users from the layout but has no visible title, such as a list of search results, give it a heading with the
sr-onlyclass, such as "Search results". - Our own choice: use the native
h1toh6elements.role="heading"witharia-levelalso counts, as a fallback when the element cannot change.
Don't
- Head the page with
<p className="text-2xl font-bold">Project settings</p>. - Build a section header as
<div className="text-lg font-semibold">Members</div>. - Replace
DialogTitlewith a styledp, so the dialog loses both its heading and its name. - Mark the small grey text under a number on a dashboard tile, such as "Open tasks", as an
h4because the tag fits. It heads nothing, which is the failure in F43. - Make the price on a plan card, "€12 a month", an
h3so it stands out. A price heads nothing.
Exceptions
- Labels of controls. A field's
labelor a group'slegendis not a heading. A label may sit inside a heading when the whole page asks one question, but that is a choice, not part of this rule. - Table captions. A table's caption names the table and is not a heading. A word above a list can be one, when it heads that part.
- Not covered here. The heading's words are STR-002b and its level is STR-003. Where a heading sits in the code relative to its part is LAY-002. The page's
titleelement is STR-001.
Verdict
Requirement. Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Requires | 1.3.1 Info and Relationships |
| Material Design | Judge | Supports | Accessibility designing: structure |
| Apple Human Interface Guidelines | Judge | Supports | VoiceOver |
| Carbon Design System | Judge | Supports | Global header Accessibility: Developers |
| GOV.UK Design System | Expert witness | Supports | Headings |
| Nielsen Norman Group | Expert witness | No position |
Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.
History
- Version 1.0.0, : First version.
Last checked against the other rules for conflicts on .
More in Page structure: 7 rules and 1 guideline · All rules
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.