Tailwind CSS tutorial #32: Screen Readers

In the article, we will go into detail on how to use Screen Readers.

Screen Readers

Format

sr-only

Tailwind Class
CSS Property

sr-only
{position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Shubhangi✨

In the article, we will go into detail on how to use Screen Readers.

Screen Readers

Format

sr-only

Tailwind Class CSS Property
sr-only {position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;}
not-sr-only {position: static; width: auto; height: auto; padding: 0; margin: 0; overflow: visible; clip: auto; white-space: normal;}

Basic usage

Screen-reader-only elements

Use sr-only to hide an element visually without hiding it from screen readers:

Undoing screen-reader-only elements

Use not-sr-only to undo sr-only, making an element visible to sighted users as well as screen readers. This can be useful when you want to visually hide something on small screens but show it on larger screens for example:

Code

<ul class="container mx-auto divide-y divide-gray-400 divide-dotted" style="font-family: Raleway">
  <li class="flex items-center justify-between px-4 py-2">
    <div class="flex flex-col items-center justify-center">
        <div class="w-1/2">
          <img class="w-24" src="http://pixelprowess.com/i/powship.svg" alt="POW Logo">
          <p class="sr-only lg:not-sr-only text-gray-500 text-2xl text-blue-300 leading-none">Lorem ipsum dolor sit amet consectetur adipisicing elit impedit officia fugiat mollitia alias ex quas modi.</p>
          <p>Voluptatibus ad distinctio, modi sed praesentium nobis quas non aperiam, recusandae illum, animi sit labore cumque in obcaecati cum laboriosam voluptas consectetur. Voluptate voluptates porro aliquid ut maiores, quidem rem!</p>
        </div>
    </div> 
    <div class="ml-5 text-right">
      <div class="text-xs font-semibold inline-block font-mono whitespace-nowrap px-2 py-1 rounded text-white bg-pink-500 rounded-2 mb-1">sr-only</div>
      <div class="text-xs font-semibold inline-block font-mono whitespace-nowrap px-2 py-1 rounded text-white bg-pink-500 rounded-2">not-sr-only</div>
    </div>
  </li>
</ul>

Full code:
The overall code will be attached to repo link.

Overall Output
Image description

Resources:
tailwind.css

Thank you for reading :), To learn more, check out my blogs on Flex Direction, Hackathons and Flex Wrap.
If you liked this article, consider following me on Dev.to for my latest publications. You can reach me on Twitter.

Keep learning! Keep coding!! đź’›


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Shubhangi✨


Print Share Comment Cite Upload Translate Updates
APA

Shubhangi✨ | Sciencx (2022-12-10T14:51:16+00:00) Tailwind CSS tutorial #32: Screen Readers. Retrieved from https://www.scien.cx/2022/12/10/tailwind-css-tutorial-32-screen-readers/

MLA
" » Tailwind CSS tutorial #32: Screen Readers." Shubhangi✨ | Sciencx - Saturday December 10, 2022, https://www.scien.cx/2022/12/10/tailwind-css-tutorial-32-screen-readers/
HARVARD
Shubhangi✨ | Sciencx Saturday December 10, 2022 » Tailwind CSS tutorial #32: Screen Readers., viewed ,<https://www.scien.cx/2022/12/10/tailwind-css-tutorial-32-screen-readers/>
VANCOUVER
Shubhangi✨ | Sciencx - » Tailwind CSS tutorial #32: Screen Readers. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/12/10/tailwind-css-tutorial-32-screen-readers/
CHICAGO
" » Tailwind CSS tutorial #32: Screen Readers." Shubhangi✨ | Sciencx - Accessed . https://www.scien.cx/2022/12/10/tailwind-css-tutorial-32-screen-readers/
IEEE
" » Tailwind CSS tutorial #32: Screen Readers." Shubhangi✨ | Sciencx [Online]. Available: https://www.scien.cx/2022/12/10/tailwind-css-tutorial-32-screen-readers/. [Accessed: ]
rf:citation
» Tailwind CSS tutorial #32: Screen Readers | Shubhangi✨ | Sciencx | https://www.scien.cx/2022/12/10/tailwind-css-tutorial-32-screen-readers/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.