CSS TRAINING · LESSON 2 OF 4 · 3 MIN READ

Set a background colour

Identify the property and an appropriate colour value.

Understand the idea

The background-color property sets an element’s background colour. Hexadecimal notation is one way to represent a colour. A background is only one part of readable design: text must remain legible against it, and colour alone should not be the only way to communicate important information.

Work through it

Use a valid colour value and check the relevant property name. Keep the selector appropriate to the element. For the exercise, use the exact requested hexadecimal value; a different colour can be valid CSS but still fail a specific brief.

SEE IT IN CONTEXT

Worked example

.card {
  background-color: #f2f6fc;
}

The declaration sets a pale background for the selected class. The example colour differs from the practice requirement so you must read and apply that requirement deliberately.

Common mistakes to avoid

  • Using the text colour property when a background is requested.
  • Omitting the # from this hex notation.
  • Choosing appearance without checking text readability.

NOW HAVE A GO

Style a clean event card

Apply the idea in the linked activity. Follow its own brief and values; examples in this lesson are illustrative.

Try the practice activity →Download the practice starter
About the linked activity

The linked CSS exercise checks exactly three declarations in one .card rule. These four lessons build toward that same activity. The checker does not apply your code to the website or implement all CSS behaviour.

Reading marks are self-reported and saved only in this browser.

0 of 4 lessons marked as read

Keep learning: Reference documentation ↗

YOUR LEARNING JOURNEY

Look how far you’ve come.

Your progress is saved in this browser. Clearing browser data removes it.

Manage saved progress

This removes your completed-challenge history from this browser.