Loading lesson path
Concept visual
Start at both ends
Overview
A website should be designed to ensure good accessibility for all users, including those with disabilities. CSS accessibility styling is about using good styling technics to improve the visual clarity, navigation, and overall user experience.
Here are some tips and technics on how to improve the accessibility of your web site:
Good Color Contrast body {
background-color: #ffffff;
color: #000000;
}
Bad Color Contrast body {
background-color: #eeeeee;
color: #cccccc;
}Good Font Example body {
font-family: Arial, sans-serif;
font-size: 1rem;
line-height: 1.6;
}
Bad Font Example body {
font-family: Georgia, serif;
font-size: 12px;
font-style: italic;
font-variant: small-caps;
line-height: 90%;
}:focus pseudo-class to ensure that interactive elements (like links, buttons, input fields) have a clear visual focus style.
Formula
:focus will ensure that keyboard users and screen - readers understand which element is currently active.Example a:focus, button:focus, input:focus {
outline: 2px solid orange;
}outline: none;
}Good Example button:focus {
outline: 2px solid orange;
}Formula
5. Use CSS + Semantic HTMLUse CSS for visual styling, and structure content with semantic HTML elements
Formula
(instead of non - semantic elements, like<div> for everything).
Example nav {
background-color: #333333;
color: white;
}
aside {
background-color: #333333;
color: white;
}Formula
prefers - reduced - motion@media feature lets you check if a user has asked to reduce motion, such as animations or transitions. Some users have motion sensitivity and prefer websites with less animation. You can use this media query to turn off, or tone down animations and transitions for the users who has activated this setting on their computer:
@media (prefers-reduced-motion: reduce) {
* {
animation: none !important;
transition: none !important;
}
}You will learn more about media queries in a later chapter.