1023 B
1023 B
title, tags, firstSeen, lastUpdated
| title | tags | firstSeen | lastUpdated |
|---|---|---|---|
| Offscreen | layout,visual,intermediate | 2018-03-30T18:50:31+03:00 | 2020-12-30T15:37:37+02:00 |
Completely hides an element visually and positionally in the DOM while still allowing it to be accessible.
- Remove all borders and padding and hide the element's overflow.
- Use
clipto indicate that no part of the element should be shown. - Make the
heightandwidthof the element1pxand negate them usingmargin: -1px. - Use
position: absoluteso that the element does not take up space in the DOM. - Note: This provides an accessible and layout-friendly alternative to
display: none(not readable by screen readers) andvisibility: hidden(takes up physical space in the DOM).
<a class="button" href="https://google.com">
Learn More <span class="offscreen"> about pants</span>
</a>
.offscreen {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}