Color plays a major role in a user’s ability to read the information located on a page. If colors lack sufficient contrast, they can become hard to distinguish from one another. Oftentimes, text can become lost in the background color, which prevents users, especially those with vision impairments, from reading it. The solution to this is to provide adequate contrast between foreground and background elements. To understand contrast, we must first understand where it comes from: the color wheel.

diagram of the color wheel

Two colors are contrasting when they are from different segments of the color wheel. Thus, the farther apart the segments, the higher the contrast between the two colors. The difference between the two colors is known as the contrast ratio and a minimum contrast ratio must be met in order to adhere to accessibility standards. The minimum contrast ratio denotes how high the contrast is between the text of certain sizes and width on a specific background. This ratio can range from 1:1, where both compared colors are the same, to 21:1, where the two colors are black and white.

contrast ratio

According to the Web Content Accessibility Guidelines (WCAG), contrast ratios are classified using a 3-tier hierarchy:

  • Level A is the minimum level.
  • Level AA includes all Level A and AA requirements. Many organizations strive to meet Level AA.
  • Level AAA includes all Level A, AA, and AAA requirements.

The recommended minimum contrast ratios between the background and its text using these standards are as follows:

  • 4.5:1 (AA criteria)—Text that is less than 24px (not bold) and 19px (bold).
  • 3:1 (AA criteria)—Text larger than 24px (not bold) and 19px (bold).
  • 7:1 (AAA criteria)—Text that is less than 24px (not bold) and 19px (bold).
  • 4.5:1 (AAA criteria)—Text larger than 24px (not bold) and 19px (bold).

There are a variety of tools that can be used to determine contrast ratios. The Chrome Canary browser has a built-in contrast ratio display inside its developer tools. Another popular stand-alone tool is WebAIM.



Currently, the background color of the .survey-form element has low contrast relative to its text. Based on the characteristics of the text choose the pair of colors that meet accessibility standards from the following list:

  • #FFFFFF (Background) and #FFFF22 (Text)
  • #C3C3C3 (Background) and #000000 (Text)
  • #FD8480 (Background) and #FD67FF (Text)

Apply the color pair with the minimum contrast ratio of 4.5:1 to .survey-form element as values of the background-color and color properties, respectively.


Modifying the background color from the previous step has caused our input fields in our form to lose contrast between their borders and the background, rendering them hard to see. Set the border color of the .survey-form input elements to #000000 to provide proper contrast.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?