CSS TRAINING · LESSON 3 OF 4 · 3 MIN READ

Add inner space with padding

Distinguish space inside an element from space outside it.

Understand the idea

Padding is space between an element’s content and its border area. Margin is space outside the border. They can affect a layout in different ways. A single padding value applies to all four sides, which is useful for a small card that needs even inner spacing.

Work through it

Decide whether the problem is crowded content inside the card or distance between neighbouring cards. Use padding for the inner gap in this lesson. Include a unit where required and inspect small screens as well as wide ones. The practice checker compares the requested declaration rather than rendering a complete layout.

SEE IT IN CONTEXT

Worked example

.card {
  padding: 20px;
}
This adds 20 pixels of padding on every side.

The content gets room inside its container. This is different from pushing the entire card away from neighbouring elements with margin. Use the exercise’s requested amount when practising.

Common mistakes to avoid

  • Using margin when the brief asks for inner spacing.
  • Writing a nonzero length without the required unit.
  • Assuming a desktop layout will fit every phone.

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.