Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

CSS Tutorial

CSS HOME CSS Introduction CSS Syntax CSS Selectors CSS How To CSS Comments CSS Errors CSS Colors CSS Backgrounds CSS Borders CSS Margins CSS Padding CSS Height/Width CSS Box Model CSS Outline CSS Text CSS Fonts CSS Icons CSS Links CSS Lists CSS Tables CSS Display CSS Max-width CSS Position CSS Z-index CSS Overflow CSS Float CSS Inline-block CSS Align CSS Combinators CSS Pseudo-classes CSS Pseudo-elements CSS Opacity CSS Navigation Bars CSS Dropdowns CSS Image Gallery CSS Image Sprites CSS Attr Selectors CSS Forms CSS Counters CSS Units CSS Specificity CSS !important CSS Math Functions CSS Optimization CSS Accessibility CSS Website Layout

CSS Advanced

CSS Rounded Corners CSS Border Images CSS Backgrounds CSS Colors CSS Color Keywords CSS Gradients CSS Shadows CSS Text Effects CSS Custom Fonts CSS 2D Transforms CSS 3D Transforms CSS Transitions CSS Animations CSS Tooltips CSS Image Styling CSS Image Modal CSS Image Centering CSS Image Filters CSS Image Shapes CSS object-fit CSS object-position CSS Masking CSS Buttons CSS Pagination CSS Multiple Columns CSS User Interface CSS Variables CSS @property CSS Box Sizing CSS Media Queries CSS MQ Examples

CSS Flexbox

Flexbox Intro Flex Container Flex Items Flex Responsive

CSS Grid

Grid Intro Grid Columns/Rows Grid Lines Grid Container Grid Item CSS @supports

CSS Responsive

RWD Intro RWD Viewport RWD Grid View RWD Media Queries RWD Images RWD Videos RWD Frameworks RWD Templates

CSS SASS

SASS Tutorial

CSS Examples

CSS Templates CSS Examples CSS Editor CSS Snippets CSS Quiz CSS Exercises CSS Website CSS Syllabus CSS Study Plan CSS Interview Prep CSS Bootcamp CSS Certificate

CSS References

CSS Reference CSS Selectors CSS Combinators CSS Pseudo-classes CSS Pseudo-elements CSS At-rules CSS Functions CSS Reference Aural CSS Web Safe Fonts CSS Animatable CSS Units CSS PX-EM Converter CSS Colors CSS Color Values CSS Default Values CSS Browser Support

CSS Accessibility Styling


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:

1. 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

body {
  background-color: #ffffff;
  color: #000000;
}
Try it Yourself »

Bad Color Contrast

body {
  background-color: #eeeeee;
  color: #cccccc;
}
Try it Yourself »

2. 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

body {
  font-family: Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}
Try it Yourself »

Bad Font Example

body {
  font-family: Georgia, serif;
  font-size: 12px;
  font-style: italic;
  font-variant: small-caps;
  line-height: 90%;
}
Try it Yourself »

3. 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

a:focus, button:focus, input:focus {
  outline: 2px solid orange;
}
Try it Yourself »


4. Avoid Hiding Focus

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

Bad Example

button:focus {
  outline: none;
}
Try it Yourself »

Good Example

button:focus {
  outline: 2px solid orange;
}
Try it Yourself »

5. 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;
}

6. 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

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
Try it Yourself »

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

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.