How do CSS display and visibility rules affect screen readers?

CSS can determine whether content appears in the accessibility tree as well as whether it is visible. Elements hidden with display: none or visibility: hidden, including their descendants, are generally not announced by screen readers. That is appropriate for content that is genuinely unavailable in the current state.
The properties differ visually. display: none removes the element from layout, while visibility: hidden normally preserves its space. Both remove it from ordinary accessibility exposure. The HTML hidden attribute provides similar intent for content that should not currently render.
A collapsed disclosure can use one synchronized state:
<button aria-expanded="false" aria-controls="details">Show details</button>
<div id="details" hidden><p>Delivery takes two business days.</p></div>
Other visual techniques behave differently. opacity: 0 makes content transparent but can leave it in the accessibility tree and keyboard order. Off-screen visually hidden text is intentionally kept available to screen readers and should be limited to useful labels or context. A visually hidden utility class must avoid clipping focusable elements in a way that makes keyboard focus disappear from sight. display: contents has had accessibility-tree inconsistencies, particularly when applied to semantic elements, so test it carefully before relying on preserved roles.
When showing or hiding interactive content, update visual state, keyboard focus and ARIA state together. A hidden panel must not contain reachable controls, and focus should not be left on an element that disappears. Inspect the accessibility tree and test transitions with a keyboard and screen reader, because CSS that looks correct can still expose ghost controls or remove needed information.