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.

Keep reading

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>
Don't do this
Keep reading

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;
}
Keep reading

More posts

  1. The geolocation element is odd

  2. Your skip link targets may not need tabindex=-1 to work properly

  3. role=presentation is no alternative for aria-hidden=true

  4. Put aria-hidden=true on decorative SVGs

  5. aria-haspopup might not do what you think it does

  6. A new meta tag for respecting text scaling on mobile

  7. Introduction to the new HTML element <geolocation>

  8. Lowering the specificity of multiple rules at once

  9. My favourite front-end and web development conferences

  10. Better defaults for popovers

  11. Workshop: Deep Dive on Accessibility Testing