Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Hiding Elements in CSS: The Accessible Way

Hiding elements in your UI is common, but doing so in an accessible manner ensures you don’t unintentionally exclude some users. In this article, we’ll cover three scenarios: Hiding elements from screen readers. Showing elements to only s…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Hiding elements in your UI is common, but doing so in an accessible manner ensures you don’t unintentionally exclude some users. In this article, we’ll cover three scenarios:




  1. Hiding elements from screen readers.

  2. Showing elements to only screen readers.

  3. Hiding elements from all users, including screen readers.



Each section includes code examples and practical use case









Hiding elements from screen readers



If you want an element to be visible to sighted users but hidden from screen readers, you can use the aria-hidden="true" attribute or CSS.




<div aria-hidden="true">This content is hidden from screen readers.</div>









Use cases




  1. Hiding background images

  2. Decorative icons or visual elements that don’t convey meaningful information.




<button>
<span aria-hidden="true">+</span>
Add Item
</button>









Showing elements to only screen readers



To make an element visible to screen readers but invisible to sighted users, you can use the "visually hidden" technique. Tailwind CSS provides a prebuilt utility class, sr-only, for this purpose.




<div class="sr-only">
This content is only visible to screen readers.
</div>






Writing the sr-only class in CSS would look like this




.sr-only {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}









Use cases





  1. For labeling interactive elements like inputs without visually displaying the text:


    <label for="username" class="sr-only">Username</label>
    <input type="text" id="username" name="username">




  2. Providing additional information for screen reader users using aria-describedby


    <div class="sr-only" id="instructions">
    Password must include 8 characters, one number, and one special
    symbol.
    </div>
    <input type="password" aria-describedby="instructions">



  3. Hiding Input Elements for Custom Radio Buttons

    When creating custom radio buttons (or checkboxes), you often hide the native input element and replace it with a visually styled element. To do this accessibly, the hidden input must remain visible to screen readers.







Hiding Elements from All Users



To completely hide an element from both sighted users and screen readers, you can use display: none or visibility: hidden.




.hidden {
display: none;
/* or visibility: hidden; */
}






Apply the class:




<div class="hidden">This content is hidden from all users.</div>









TL;DR



Here’s a table summarizing how various CSS attributes affect visibility for different types of users:





















































































CSS Attribute Hides for All Users Hides for Sighted Users Hides for Screen Readers Notes
display: none Completely removes the element from the visual and accessibility tree.
visibility: hidden Hides the element visually but keeps it in the layout and accessibility tree.
opacity: 0 Makes the element fully transparent but still visible to screen readers and interactive.
clip: rect(0, 0, 0, 0) Commonly used in the "visually hidden" technique; removes visual rendering but accessible.
position: absolute; width: 1px; height: 1px; Used with the "visually hidden" technique; keeps elements accessible to screen readers.
aria-hidden="true" Removes the element from the accessibility tree but leaves it visually present.
overflow: hidden ✅ (if out of bounds) Hides content visually if it overflows the container but does not affect screen readers.
height: 0; width: 0; Hides content visually while keeping it accessible to screen readers.
z-index: -1 Moves the element behind others, making it invisible to sighted users but screen reader-accessible.
opacity: 0; pointer-events: none; Makes an element fully transparent and non-interactive, but accessible to screen readers.
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Hiding Elements in CSS: The Accessible Way

Thematisch verwandte Begriffe: Hiding, Elements, Accessible · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94097 | A vulnerability was determined in Netcore NBR200V2 1.3.241127.071246. Th…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick