惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Spread Privacy
Spread Privacy
K
Kaspersky official blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Forbes - Security
Forbes - Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Last Watchdog
The Last Watchdog
SecWiki News
SecWiki News
Attack and Defense Labs
Attack and Defense Labs
Google DeepMind News
Google DeepMind News
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Secure Thoughts
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
Security Latest
Security Latest
TaoSecurity Blog
TaoSecurity Blog
Cyberwarzone
Cyberwarzone
S
SegmentFault 最新的问题
Cloudbric
Cloudbric
aimingoo的专栏
aimingoo的专栏
S
Schneier on Security
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
T
The Blog of Author Tim Ferriss
H
Hacker News: Front Page
C
Cybersecurity and Infrastructure Security Agency CISA
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
AWS News Blog
AWS News Blog
AI
AI
G
GRAHAM CLULEY
IT之家
IT之家
P
Privacy & Cybersecurity Law Blog
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
D
Docker
Recent Announcements
Recent Announcements
O
OpenAI News
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
Troy Hunt's Blog
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic

TetraLogical Blog

Designing for people with reading disabilities - TetraLogical Designing for people who are D/deaf - TetraLogical Designing accessible documents - TetraLogical Introduction to creating accessible documents - TetraLogical Inclusive user research: vulnerable people - TetraLogical Designing for people who are blind - TetraLogical Designing for people with low vision - TetraLogical Meet the team: Niamh Madden - TetraLogical Designing for people with anxiety - TetraLogical Designing for people with disabilities - TetraLogical Accessible building blocks for the web videos - TetraLogical Common accessibility misconceptions - TetraLogical Common misconceptions about testing accessibility - TetraLogical Common misconceptions about implementing accessibility - TetraLogical Common misconceptions about WCAG - TetraLogical Common misconceptions about disability - TetraLogical Meet the team: Grace Snow - TetraLogical Sustainable accessibility in complex organisations: strategic foundations - TetraLogical Sustainable accessibility in complex organisations: organisational realities - TetraLogical Sustainable accessibility in complex organisations: external factors - TetraLogical Common misconceptions about screen readers - TetraLogical Guide to the Inclusive Design Principles - TetraLogical Meet the team: Ian Lloyd - TetraLogical Annotating designs using common language - TetraLogical Meet the team: Catriona Morrison - TetraLogical Championing inclusive language - TetraLogical Press release: TetraLogical launches accessible self-led training courses to help digital teams build confidence in accessibility - TetraLogical Why inclusive products are green products - TetraLogical Accessible Recruitment - TetraLogical Accessibility and the agentic web - TetraLogical Meet the team: Craig Abbott - TetraLogical Foundations: types of assistive technology and adaptive strategies - TetraLogical European Accessibility Act (EAA) FAQ - TetraLogical Screen reader HTML support tables - TetraLogical Interview with Lola Odelola - TetraLogical Understanding EN 17161 Design for All - TetraLogical Inclusive user research: building rapport - TetraLogical Foundations: Keyboard accessibility - TetraLogical Can generative AI write contextual text descriptions? - TetraLogical Understanding the European Accessibility Act (EAA) - TetraLogical Meet Josh: a sportsman who has spinal muscular atrophy - TetraLogical Meet Jonathan: a photographer who has ADHD - TetraLogical Foundations: grouping forms with `<fieldset>` and `<legend>` - TetraLogical XR Accessibility: for people with moving disabilities - TetraLogical Meet Andre: a music producer and blind screen reader user - TetraLogical Foundations: types of disability - TetraLogical Meet Lauren: a film editor who has ADHD - TetraLogical Meet Steve: a photographer who is deaf and low vision - TetraLogical Foundations: form validation and error messages - TetraLogical Meet Hasmukh: a blind cricketer and screen reader user - TetraLogical XR Accessibility: for people with hearing disabilities - TetraLogical XR Accessibility: for people with thinking disabilities - TetraLogical XR Accessibility: for people with seeing disabilities - TetraLogical Introduction to XR Accessibility - TetraLogical Foundations: labelling text fields with input and label - TetraLogical Design patterns and WCAG - TetraLogical Does WCAG 2.2 apply to native apps - TetraLogical Why are my live regions not working? - TetraLogical Building a culture of accessibility - TetraLogical When to use tabindex= Accessibility foundations - TetraLogical Meet the team: Demelza Feltham - TetraLogical Can generative AI help write accessible code? - TetraLogical Meet the team: Steve Faulkner - TetraLogical Meet the team: Gez Lemon - TetraLogical Keyboard accessibility myths and WCAG - TetraLogical Amendment to the Public Sector Accessibility Regulations - TetraLogical What Considerations for TV user interface accessibility - TetraLogical Meet the team: Alistair Duggin - TetraLogical Sticky content: focus in view - TetraLogical The only accessibility specialist in the room - TetraLogical Meet the team: Ian Pouncey - TetraLogical Meet the team: Dean Holden - TetraLogical Meeting WCAG Level AAA - TetraLogical Foundations: accessible names and descriptions - TetraLogical Inclusive XR: accessible augmented reality experiences - TetraLogical Foundations: pointer gestures - TetraLogical Meet the team: Graeme Coleman - TetraLogical Adding sign language to videos - TetraLogical Foundations: introduction to WAI-ARIA - TetraLogical Meet the team: Joe Lamyman - TetraLogical Inclusive XR: accessible 3D experiences - TetraLogical Foundations: visible focus styles - TetraLogical Foundations: target sizes - TetraLogical Meet the team: Henny Swan - TetraLogical Meet the team: Ela Gorla - TetraLogical Foundations: native versus custom components - TetraLogical Accessibility and supporting Internet Explorer - TetraLogical Meet the team: Felicity Miners-Jones - TetraLogical Accessibility and QR codes - TetraLogical Inclusive user research: recruiting participants - TetraLogical Research insight: accessibility of images - TetraLogical Meet the team: Léonie Watson - TetraLogical Android accessibility: roles and TalkBack - TetraLogical Accessible design systems - TetraLogical Meet the team: Patrick H. Lauke - TetraLogical Inclusive user research: analysing findings - TetraLogical How to write user stories for accessibility - TetraLogical Triaging WCAG 2.1 Level AAA - TetraLogical
Foundations: HTML semantics - TetraLogical
2022-10-05 · via TetraLogical Blog

Posted on by Henny Swan in Design and development

Tags: Assistive Technology, Code, Foundations, WCAG

HTML semantics provide accessibility information about page structure and an element's role, name, and state, helping to convey the nature and purpose of content on web pages.

In this post we explore what HTML semantics are, and how they're experienced by people using assistive technologies like screen readers and speech recognition software.

HTML semantics are processed by web browsers, then used by assistive technologies so that people with disabilities can understand what elements are and how to interact with them. An assistive technology is a software that people use to access web content. This could be a screen reader which announces content to people who are blind, or speech recognition software that people with physical disabilities use to navigate content using their voice.

Structure

You can use HTML to give content structure by identifying things like headings, lists, paragraphs, and data tables. Writing semantic code means choosing the most appropriate element to identify the content and therefore the structure.

For example, HTML headings are identified using the elements <h1> to <h6>. A screen reader will announce "heading level one” for a <h1>, “heading level two” for <h2> and so on. This gives people who use a screen reader an understanding of the heading hierarchy of a page, much like a table of contents in a book.

In the following example, a screen reader will announce the headings as "Heading level 1, About TetraLogical" and "Heading level 2, Our principles".

<h1>About TetraLogical</h1>
<p>We’re a boutique company, with lots of experience and a whole new attitude.</p><h2>Our principles</h2>
<p>...TetraLogical is founded on four principles that mean everything we do is:</p>
<ul>
  <li>Inclusive...</li>
  <li>Sustainable...</li>
  <li>Ethical...</li>
  <li>Original...</li>
</ul>

Lists are announced when the <ul> or <ol> elements and <li> are used. In the above example a screen reader will announce “List of four items” (or similar). It will also announce where in the list the item is and what it is, for example "Sustainable, two of four".

A heading level 1 for About TetraLogical, a heading level 2 for Our Principles, and an unordered list of the About TetraLogical page

Role

An element's role describes its purpose. Roles are announced by screen readers and indicate the type of element something is, for example a link, button, radio button, or checkbox. Many HTML elements have a default role, also known as the implicit role.

For example, the implicit role of the <a> element is "link". When the browser processes the following code it automatically assigns a role of "link" to the element:

<a href="https://www.tetralogical.com/">TetraLogical</a>

This means people browsing with a desktop screen reader will hear "TetraLogical link" and people browsing with speech recognition software, can say "Click TetraLogical link" to interact with it.

Another example is buttons. The browser assigns a role of "button" to the <button> element when the following code is used:

<button>Next</button>

People browsing with a screen reader will hear "Next, button" while people browsing with speech recognition can say "Click next button" to interact with it.

The role of an element is important because it lets people know how to interact with it. For example, when “link” is announced someone using a screen reader will know to press the Enter key to activate the link. For buttons, they will know to press the Enter key or Spacebar to activate it. The role also impacts the user experience; if you hear "link" you expect a new page to open, if you hear "button" you expect to trigger an action such as open a menu, dialog, or submit a form.

In the example form below, the text 'Sign in instead' is a link to a new page; it has a role of link, and looks like a link. The text 'Next' submits the form; it has a role of button, and looks like a button.

A link to 'Sign in instead' and a 'Next' button adjacent to each other at the bottom of a form.

Name

An element's name, or accessible name, is how it's identified. An element's name is announced by screen readers together with the role and used by speech recognition software to map an element to a voice command.

All interactive elements and components must have an accessible name. For example, the accessible name for a link comes from the content inside the anchor element. When a screen reader encounters the following code, it will announce "sustainable accessibility, link", while someone using speech recognition can say "Click sustainable accessibility link".

<a href="https://www.tetralogical.com/">sustainable accessibility</a>

A paragraph of text with the link 'sustainable accessibility' in it

The accessible name for a button comes from the content inside the <button> element. In the following example, a screen reader will announce "Sign in button", while someone who uses speech recognition can say "Click Sign in button".

<button>Sign in</button>

A simple log on form with a 'Sign in' button at the bottom

State

An element's state is its current condition. The state is announced by screen readers so that people know if, for example, a checkbox is selected or unselected, or a button is disabled or not.

In the following example a screen reader will announce “Show password, checkbox checked” because in the code it is indicated as "checked".

<label for="checkboxLabel">
<input type="checkbox" id="checkboxLabel" checked>
Show password</label>

A Show password checkbox which is checked showing a password of 'S3manticsR0ck

Extending HTML using WAI-ARIA

There are times when the HTML semantics need to be extended because they don't do everything we want. For example, there is no way in HTML to indicate if a button is pressed. The Web Accessibility Initiative Accessible Rich Internet Applications specification 1.1, or WAI-ARIA or ARIA for short, can be used to extend HTML.

ARIA complements HTML semantics by providing a set of attributes that allow you to enhance the native roles of HTML elements to build more accessible user experiences. We'll introduce how ARIA can do this in our next foundations post.

Tips for semantic HTML

  • Always use the correct semantics, for example, don't use heading elements for visual styling
  • Always use semantic HTML over ARIA when it is available. ARIA is there to fill the gaps that HTML can't reach.

More information

Next steps

Read more accessibility foundations posts or sign up for Accessibility Unlocked, our free six-day newsletter series designed to help you kick-start accessibility.