Skip to content

Instantly share code, notes, and snippets.

@luxplanjay
Last active January 13, 2026 11:14
Show Gist options
  • Select an option

  • Save luxplanjay/6f6936b1bba7afe006fa9317b07b6045 to your computer and use it in GitHub Desktop.

Select an option

Save luxplanjay/6f6936b1bba7afe006fa9317b07b6045 to your computer and use it in GitHub Desktop.
Visually hidden CSS pattern
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
clip-path: inset(100%);
clip: rect(0 0 0 0);
overflow: hidden;
}
@Serrin
Copy link

Serrin commented May 15, 2021

You can add these:

outline: 0;
outline-offset: 0;

@KostiantynO
Copy link

KostiantynO commented Jun 6, 2021

Если надо скрыть элементы от скрин-ридеров и убрать выделение табом и мышкой:

.is-hidden {
  visibility: hidden;
  pointer-events: none;
  position: absolute;
}

@moriarty15
Copy link

ty =)

@andriideikalo
Copy link

thank you!

@leonbahley
Copy link

cool. thanks

@PavloGPS
Copy link

PavloGPS commented Oct 7, 2022

Thanks)

@LipskyiAlex
Copy link

Thanks a lot!

@Nataliia9
Copy link

thanks)

@wittjeff
Copy link

Use outline: transparent instead of outline:0 for compatibility with Windows High Contrast Mode.

@Baxtiyorov092
Copy link

oooooo assalomu alekom bratiim qandaysiiz ozbela bormi Uzbekistan

@wittjeff
Copy link

visually hidden means it can be "seen" by blind people using screen readers, but not by sighted people (no part of the item styled this way is drawn visually, because the clip rect is empty, but this item is still "visible" in the DOM.)

@volodymyr-leskiv
Copy link

Thanks!

@oleksandr-danylchenko
Copy link

Unfortunately, I found that setting both width and height to 1px may not work properly for the focus-only links in iOS VoiceOver.
The VO will announce it once reached, but it won't receive the DOM focus. On click, some internal "clickability" check won't mark the link as the event's target. That'll cause the app to ignore any custom click handlers with default prevention.
After I leave just the width or just the height, the VO navigation works better, and the link is marked as a target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment