Complete the code to create a utility class that visually hides content but keeps it accessible to screen readers.
.sr-only {
position: [1];
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}The position: absolute; removes the element from the normal flow and allows it to be visually hidden while still accessible to screen readers.
Complete the mixin to generate a utility class that hides content visually but keeps it accessible.
@mixin sr-only {
position: [1];
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}The mixin uses position: absolute; to visually hide the element but keep it accessible.
Fix the error in the utility class that should visually hide content but keep it accessible.
.sr-only {
position: [1];
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}The clip property requires commas between values. Using position: absolute; is necessary to hide the element visually but keep it accessible.
Fill both blanks to create a mixin that generates a utility class for screen reader only content.
@mixin sr-only {
position: [1];
clip: [2];
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
white-space: nowrap;
border: 0;
}The position: absolute; removes the element from normal flow, and clip: rect(0, 0, 0, 0); hides it visually but keeps it accessible.
Fill all three blanks to create a reusable accessibility utility mixin with customizable position, clip, and white-space properties.
@mixin sr-utility($pos: [1], $clip: [2], $ws: [3]) { position: $pos; clip: $clip; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; white-space: $ws; border: 0; }
The mixin uses default parameters: position: relative; to position the element, clip: rect(0, 0, 0, 0); to hide it visually, and white-space: nowrap; to prevent line breaks.