Css Accessibility
In the kit: .github/skills/kb-path-instructions/references/css-accessibility.md.
-
This file as plain text, at
https://letitglow.app/ahg/kit/raw/.github/skills/kb-path-instructions/references/css-accessibility.md - Everything in the kit
Copy it into ChatGPT or another assistant
Read the plain text first
Css Accessibility
Applies to files matching **/*.{css,scss,less}.
Part of the kb-path-instructions skill.
Dependencies
web-accessibility-baseline.md(same folder) - defines the WCAG contrast ratios and focus requirements that this file enforces at the CSS level
These rules apply automatically to every CSS, SCSS, and Less file. They catch accessibility regressions that escape HTML/JSX-level enforcement.
Impact: Keyboard users rely entirely on focus indicators to know where they are on the page. Removing focus indicators without a replacement makes keyboard navigation impossible.
Focus Visibility
- Never write
outline: noneoroutline: 0without an accompanying:focus-visiblerule that provides a visible alternative (minimum2px solidoutline or box-shadow equivalent). - If removing the default outline, ALWAYS add a replacement indicator - users who navigate by keyboard rely on visible focus.
- The
:focus-visibleselector is preferred over:focusto avoid showing focus rings on mouse clicks.
Impact: Animations can trigger vestibular disorders and disable users with photosensitive epilepsy. The
prefers-reduced-motionmedia query is the only browser-level mitigation.
Motion and Animation
- Every
animationortransitiondeclaration should have a corresponding@media (prefers-reduced-motion: reduce)block that disables or reduces the motion. Exception: opacity transitions under 200ms are generally safe without an override. - Parallax effects, auto-playing carousels, and infinite animations are particularly harmful - provide a static alternative.
Impact: Small touch targets cause frequent misfires on mobile, disproportionately affecting users with motor impairments.
Touch Target Size
- Interactive elements need a target of at least 24x24 CSS px, or enough spacing from neighbouring targets (WCAG 2.5.8 Target Size (Minimum), AA).
min-height: 44px; min-width: 44pxmeets 2.5.5 Target Size (Enhanced, AAA) and the iOS and Android platform guidelines, and is the better default. - If sizing via padding, ensure the clickable area meets the minimum, not just the visible content.
Impact: Clipped focus indicators make keyboard navigation invisible - users cannot see where they are despite focus actually moving.
Overflow and Clipping
overflow: hiddennear interactive content can clip focus indicators - verify that focus rings remain fully visible.text-overflow: ellipsistruncates only visually; screen readers still read the full text, but sighted and magnifier users lose it. Give a visible way to reach the full text (expand control, or a tooltip that also appears on focus). Do not rely ontitle, and do not putaria-labelon the parent, which can replace the text for screen readers.
Impact: Low contrast is the single most commonly reported accessibility failure. It affects users with low vision, color blindness, and users in outdoor or bright-light environments.
Color and Contrast
- Do not use
colorwithout considering thebackground-colorcontext:- Normal text (< 18pt / < 14pt bold): minimum 4.5:1 contrast
- Large text (>= 18pt regular or >= 14pt bold, approximately >= 24px regular or >= 18.67px bold): minimum 3:1 contrast
- UI components (input borders, focus rings, icon buttons, chart lines): minimum 3:1 against adjacent background
opacityvalues below1reduce effective contrast - verify the computed contrast after opacity is applied.- Avoid
!importanton color/background declarations in utility classes - it prevents user stylesheet overrides for high contrast needs.
Impact:
display:nonesilently hides content from AT with no warning. Live regions set to hidden stop all announcements.
Display and Visibility
display: noneremoves elements from the accessibility tree entirely - never apply it to live regions (aria-live) or elements that screen readers need to announce.visibility: hiddenalso hides from assistive technology. Use.sr-only/.visually-hiddenpatterns when content must be hidden visually but remain accessible to screen readers.content-visibility: autocan defer accessibility tree construction - avoid on landmark regions and navigation.
Impact:
cursor: pointeron non-interactive elements signals affordance that doesn't exist and correlates with missing keyboard interaction.
Cursor
cursor: pointeron non-interactive elements (divs, spans) suggests interactivity that doesn't exist - this misleads sighted users and correlates with missing keyboard interaction.
Impact: Smooth scrolling can trigger vestibular disorders. Scroll-snap traps prevent keyboard users from navigating past snap points.
Scrolling
scroll-behavior: smoothrespectsprefers-reduced-motionin most browsers, but always include an explicit@media (prefers-reduced-motion: reduce) { scroll-behavior: auto; }override.scroll-snapcan trap keyboard users - ensure Tab and arrow keys can escape snap containers.
Impact: CSS-only modals/overlays that lack focus trapping allow keyboard users to reach content behind the overlay, which is a focus trap in reverse.
Z-Index and Layering
- High
z-indexvalues on overlays must be paired with proper focus trapping andaria-modal="true"in the HTML - CSS alone cannot make a modal accessible.