Web development Blog
A blog about web development, HTML, CSS, JavaScript, and web accessibility.
Context-aware headings in HTML
posted on
A common issue that we've probably all faced at some point is having a component that includes a heading, which sometimes should be an H2 and sometimes maybe an H3, depending on where it's used.
You can see an example of that in the screenshot below, taken from the City of Vienna's website (I translated the page into English before taking the screenshot). We see the same card component used three times. At the very beginning of the page, it follows the H1, so the heading inside the first card should be an H2. But then we have another section that starts with an H2, and here these cards should start with an H3.
Don't put aria-label on generic elements like divs
posted on
The title already tells most of the story, but here's why you must avoid labeling generic elements like divs or spans using aria-label or aria-labelledby.
<div aria-label="News">
…
</div>
box-shadow is no alternative to outline
posted on
People like to use the box-shadow property for styling focus outlines because it gives them more flexibility.
button:focus-visible {
outline: none;
box-shadow: 0 0 0px 4px blue, 0 0 0px 8px red, 0 0 0 12px blue;
}
More posts
-
The geolocation element is odd
-
Your skip link targets may not need tabindex=-1 to work properly
-
role=presentation is no alternative for aria-hidden=true
-
Put aria-hidden=true on decorative SVGs
-
aria-haspopup might not do what you think it does
-
A new meta tag for respecting text scaling on mobile
-
Introduction to the new HTML element <geolocation>
-
Lowering the specificity of multiple rules at once
-
My favourite front-end and web development conferences
-
Better defaults for popovers
-
Workshop: Deep Dive on Accessibility Testing