bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/CSS/CSS Foundations Practice
CSS•CSS Foundations Practice

CSS Accessibility Styling

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind CSS Accessibility Styling?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___-color: #ffffff;
3Order

Put the learning moves in the order that makes the concept easiest to apply.

Provide High Color Contrast
CSS Accessibility Styling Technics
CSS Accessibility Styling

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.

CSS Accessibility Styling Technics

Here are some tips and technics on how to improve the accessibility of your web site:

Provide High Color Contrast

Always use a good color contrast between the text and the background for readability. This is especially important for users with visual impairments or color blindness.

Good Color Contrast

Formatted code
body {
  background-color: #ffffff;
  color: #000000;
}

Live preview

Bad Color Contrast

Formatted code
body {
  background-color: #eeeeee;
  color: #cccccc;
}

Live preview

Provide Good Font, Font Size and Line Height

Always provide a font that is easily readable. In addition, use a proper font size and line height. Use relative units (like rem ) for font-size , to allow the user to scale the text size in the browser settings.

Good Font Example

Formatted code
body {
  font-family: Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

Live preview

Bad Font Example

Formatted code
body {
  font-family: Georgia, serif;
  font-size: 12px;
  font-style: italic;
  font-variant: small-caps;
  line-height: 90%;
}

Live preview

Have Visible Focus Indicators

Always use the :focus pseudo-class to ensure that interactive elements (like links, buttons, input fields) have a clear visual focus style.

Using :focus will ensure that keyboard users and screen-readers understand which element is currently active.

Example

Formatted code
a:focus, button:focus, input:focus {
  outline: 2px solid orange;
}

Live preview

Avoid Hiding Focus

Never remove the default focus outlines, without replacing them with another visible focus style.

Bad Example

Formatted code
button:focus {
  outline: none;
}

Live preview

Good Example

Formatted code
button:focus {
  outline: 2px solid orange;
}

Live preview

Use CSS + Semantic HTML

Use CSS for visual styling, and structure content with semantic HTML elements (instead of non-semantic elements, like <div> for everything).

Example

nav {
 background-color: #333333;
 color: white;
}
aside {
 background-color: #333333;
 color: white;
}

Respect User Preferences

The CSS 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:

Example

Formatted code
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

Live preview

You will learn more about media queries in a later chapter.

Summary

  • Provide high color contrast
  • Provide easily readable fonts
  • Keep focus outlines visible
  • Use semantic HTML elements
  • Respect user preferences

Previous

CSS Performance Optimization

Next

CSS Website Layout