Back to Unit 6

Unit 6 Website Development - Tutorial 2

2.9 Use padding to control space inside an element

Stop text touching the edge of a box.

What You Are Adding

Padding creates space inside an element, between the content and the border. It makes cards, buttons, headers and notices easier to read because the content is not pressed against the edge.

CSS To Add To css/style.css

Add or adapt this CSS in the stylesheet you created in Tutorial 1. Keep the HTML structure from Tutorial 1 and use CSS to improve the presentation.

.notice {
    padding: 18px;
    border: 2px solid #dca311;
    background-color: #fff9df;
}

Expected Output

The text has breathing room inside the notice box.

Build It Yourself

  1. Open the same unit-6-website folder from Tutorial 1.
  2. Add or update the relevant HTML class names if this page uses classes.
  3. Add the CSS shown above to css/style.css.
  4. Save the stylesheet and refresh the website in the browser.
  5. Compare your page with the expected output preview.

Common Mistakes

Success Checklist