Your daily frequent11y newsletter, brought to you by @ChrisBAshton:

- Kitty Giraudel writes about the HTML attributes and CSS properties commonly used to ‘hide’ content, either visually or from assistive technologies (AT), or both. They then go into detail on each one:
- An
sr-only
class is great for visually hiding something while preserving it for AT. aria-hidden
is great for hiding content from AT while keeping it visually displayed (e.g. decorative SVGs). However, make sure that there are no focusable elements within these areas, as they are still focusable.display: none
or thehidden
attribute hide content from everyone, although their contents can still be referenced viaaria-describedby
/aria-labelledby
, which could be handy to avoid vocalising something twice. Use this overwidth: 0
andheight: 0
.visibility: hidden
hides content visually and from AT (equivalent todisplay: none
) but keeps the space, helping to avoid layout shift. Generally you’ll want to use this overopacity: 0
andclip-path: circle(0)
, which are inconsistently treated by AT, and overtransform: scale(0)
, which has limited uses.- You’ll also want to use
visibility: hidden
over the Chrome-onlycontent-visibility: hidden
, which has low browser support.
- An
Prefer longer newsletters? You can subscribe to week11y, fortnight11y or even month11y updates! Every newsletter gets the same content; it is your choice to have short, regular emails or longer, less frequent ones. Curated with ♥ by developer @ChrisBAshton.