Setting basic styles to enhance accessibility

CSS in an of itself is neutral when it comes to accessibility. Just like with our HTML markup and our scripts it is how we use this tool that can either enhance or detract from accessibility.

Setting styles on the body

The choice of font-size, color, background-color, and to some extent font-family and font-weight can have a strong effect on the accessibility of our document. Setting these properties within the body allows us to take advantage of inheritance. It also makes it easier for a color blind or low vision user to override our settings for the entire document.

Setting styles for consistency among commonly used elements

Now that we have set the styles for the body we can set styles for the most common element, headings and paragraphs. First take control of margins and padding on the heading elements together. A convenient way to make these elements to behave in a similar fashion is set them all at the same time. This is achieved by grouping them in a single style definition.

h1, h2, h3, h4 {
padding:0;
margin:.5em 0 .5em 0;
font-weight:800;
}

After setting the shared properties of these elements set the individual properties

h1 {
font-size:2.25em;
}
h2 { font-size:1.85em;
}
h3 {
font-size:1.45em;
}
h4 { font-size:1.25em;
}

Finally setting the line-height property of the of the paragraph element and the bottom-margin property of the list-item element gives spreads things out a little and improves readability.

Next

Previous

Index