
Try each exercise before revealing the example solution. Compare your result with the original visual references and CodePen demos.
1. Combine selectors
Complete style rules for all elements of a type, a class, and a descendant inside a container. Compare how they match when several rules apply.
Show one possible solution
p { color: #243248; }
.notice { font-weight: 700; }
article a { text-decoration: underline; }2. Format text
Style a heading and a block of text using text alignment, indentation, spacing, and line height.
Show one possible solution
h1 { text-align: center; }
p { text-indent: 1em; line-height: 1.6; }3. Build a call to action with a background image
Create a section with a heading, descriptive text, and a link. Add a background image, a readable overlay, and room around the text.
Show one possible solution
.cta-container { padding: 3rem 1rem; color: white; background: linear-gradient(#0008, #0008), url("cover.jpg") center / cover; }4. Make a list with an emoji marker
Use ::before to add a decorative marker. Preserve list markup and keep the meaning in the text.
Show one possible solution
.emoji-list li::before { content: "😻"; margin-inline-end: .5em; }5. Create a horizontal menu
Build a list of four navigation links. Make the links easy to select and check their keyboard focus.
Show one possible solution
.menu { display: flex; flex-wrap: wrap; gap: .75rem; }6. Make a breadcrumb
Place links to parent pages in a labeled navigation region. Mark the current page and add a separator between items.
Show one possible solution
.breadcrumbs { display: flex; flex-wrap: wrap; gap: .5rem; }
.breadcrumbs li + li::before { content: "/"; margin-inline-end: .5rem; }7. Create a vertical menu
Reuse the link list and make each link fill the row. Compare hover and keyboard focus states.
Show one possible solution
.vertical-menu a { display: block; padding: .6rem 1rem; }8. Build an image gallery
Group images and optional captions. Use flexible columns and size the images so they remain within their cards.
Show one possible solution
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: 1rem; }
.gallery img { width: 100%; height: auto; }9. Style a product table
Give the table a caption and proper headers, then add borders, spacing, and visual separation between rows.
Show one possible solution
.styled-table { border-collapse: collapse; }
.styled-table :is(th, td) { padding: .6rem; border: 1px solid #ccc; }
.styled-table tbody tr:nth-child(even) { background: #eef4fa; }10. Control overflowing content
Put a long passage in a constrained box. Compare auto, hidden, and scroll.
Show one possible solution
.scroll-box { max-block-size: 12rem; overflow: auto; }11. Style a product thumbnail
Build a compact product card with an image, title, and price using ordinary block layout. Keep the image responsive without using Bootstrap, Flexbox, or Grid.
Show one possible solution
.product { max-width: 16rem; padding: 1rem; border: 1px solid #ccc; }
.product img { display: block; width: 100%; height: auto; }Ready for a harder set? Try the intermediate and advanced CSS exercises.
Original CodePen examples
- Open example 1
- Open example 2
- Open example 3
- Open example 4
- Open example 5
- Open example 6
- Open example 7
- Open example 8
- Open example 9
- Open example 10
- Open example 11
Visual references from the original lesson





