28
loading...
This website collects cookies to deliver better user experience
Prerequesites: I will assume you have some basic understandig of accessibility concepts, if you don’t I recommend to read “Part 1: Introduction” and “Part 2: 5 priciples you should start implementing right away” befor you dive into this one.
<form>
<label>Name</label>
<input type="text"></input>
<label>Focus trap </label>
<input type="text" onBlur="this.focus()"></input>
<label>Unreachable</label>
<input type="text"></input>
</form>
@media (prefers-reduces-motion){
//do things to reduce motion here
}
@media (prefers-reduces-motion: no-preference){
//do things to create motion here
}
window.matchMedia('prefers-reduced-motion')
to see if the user has prefered reduced motion on or not. The function will return an object with a property “matches” that will be true if the user has set the prefers reduced motion.const userPreferReducedMotion =
window.matchMedia('prefers-reduced-motion');
const reducedMotionSettingListener = () => {
if(userPreferReducedMotion.matches){
//do the motion things here
}
}
userPreferReducedMotion.addListener(reducedMotionSettingListener);
<p aria-hidden="true">
The content of this paragraph will be ignored by screen readers.
</p>
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
.myClass::before{
content: "This content is not available for screen readers"
}
.myClass::after{}