Back to Unit 6

Unit 6 Website Development - Tutorial 2

2.3 Use class selectors for reusable styles

Create styles that can be applied to selected elements.

What You Are Adding

A class selector starts with a full stop in CSS, such as .club-card. In HTML, the same class name is added without the full stop. Classes let you reuse a style on several elements without styling every article on the website.

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.

.club-card {
    padding: 18px;
    border: 2px solid #b9c8f8;
    border-radius: 8px;
    background-color: white;
}

Expected Output

Websites

Build pages with HTML and CSS.

Games

Create interactive projects.

Apps

Plan simple app ideas.

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