Visually hide an element with CSS

Categories

If you hide an element with display: none, it can also hide it from assistive technology, such as screen readers.

Using a visually hidden utility, you get the best of both worlds. A visually hidden element and assistive technology can still access it.

Code language
CSS
.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: auto;
  margin: 0;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  white-space: nowrap;
}

Hello, I’m Andy and I’ll help you build fast & visually stunning websites.

I am currently setting up a new creative agency called Set Creative Studio and we are taking on projects for 2022, so if you have a project in mind, get in touch.