Estimated time: 30 minutes or more
Project: Build a responsive course landing page for CSS from Scratch, using one HTML file with CSS inside a <style> element.
This is the final lesson: you’ve completed all 12 lessons. The project brings together the CSS skills from the course in one practical page.
What you’ll practise
You’ll use semantic HTML, the box model, typography, colour, sizing, positioning, Flexbox, Grid and responsive design together. You’ll also check keyboard focus, image behaviour and layout at different widths.
1. The brief
Create a landing page for a beginner course called CSS from Scratch. It should include:
- A header with the course name and navigation.
- An introduction that explains what the course offers.
- A lesson list or set of lesson cards.
- A call to action or progress indicator.
- A footer.
Choose your own copy, colours and layout. The goal is to make the page readable and usable, not to add every visual effect you know.
2. Start with the HTML structure
Create a new file in VS Code called index.html. Add this starter structure, then replace the bracketed notes with your own content:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CSS from Scratch</title>
<style>
/* Add your CSS here */
</style>
</head>
<body>
<header class="site-header">
<!-- Course name and navigation -->
</header>
<main>
<section class="intro">
<!-- Course introduction and main action -->
</section>
<section class="lessons" aria-labelledby="lessons-title">
<h2 id="lessons-title">Course lessons</h2>
<!-- Lesson cards or list -->
</section>
</main>
<footer class="site-footer">
<!-- Footer content -->
</footer>
</body>
</html>Use headings in a sensible order: usually one main <h1> for the page, then <h2> headings for the major sections, with lower-level headings for content inside them.
3. Establish your CSS foundation
Start with a small reset and base styles. A few consistent choices make the rest of your styling easier to manage.
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial, sans-serif;
line-height: 1.5;
}
img {
display: block;
max-width: 100%;
height: auto;
}Now choose a small palette and spacing scale. You can write these values directly in your rules, or use CSS custom properties if you’re comfortable with them.
:root {
--ink: #172033;
--surface: #ffffff;
--page: #f4f7fb;
--accent: #2563eb;
--space: 1rem;
}Custom properties are optional. What matters is using colours and spacing consistently.
Quick check 1: Why is box-sizing: border-box useful when you set widths?
4. Build a readable header with Flexbox
The header is a good place to use Flexbox because its content usually sits along one row.
.site-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 1rem;
}If the items become crowded on a narrow screen, let them wrap:
.site-header {
flex-wrap: wrap;
}Use meaningful link text. A link labelled “Lessons” is clearer than “Click here”.
5. Style the introduction
Give the introduction a clear hierarchy: a main heading, a short explanation and an action link or button.
.intro {
padding: 3rem 1rem;
}
.intro h1 {
font-size: clamp(2rem, 5vw, 4rem);
line-height: 1.1;
}
.intro p {
max-width: 42rem;
}clamp() lets the heading scale fluidly within a minimum and maximum. The maximum width on the paragraph helps keep long lines comfortable to read.
6. Lay out lesson cards with Grid
Grid is useful for a group of cards because you can control rows and columns.
.lessons {
padding: 1rem;
}
.lesson-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
gap: 1rem;
}Each lesson card should have a clear title and short description. If you include a badge such as “Start here”, position it inside the card:
.lesson-card {
position: relative;
padding: 1.25rem;
border: 1px solid #d5dce8;
border-radius: 0.75rem;
background: #ffffff;
}
.lesson-card__badge {
position: absolute;
top: 0.75rem;
right: 0.75rem;
}Because the card is position: relative, the absolutely positioned badge uses the card as its anchor. Make sure it doesn’t cover the heading or other important content.
7. Add a responsive change
The auto-fitting Grid above will change the number of columns as space allows. You can also add a media query when your design needs a deliberate change at a particular width:
@media (min-width: 48rem) {
.intro {
padding: 5rem 2rem;
}
}Treat 48rem as a starting example, not a device rule. Resize the page and choose a breakpoint where your content needs more room.
Keep the main content from becoming too wide:
main {
width: min(100% - 2rem, 72rem);
margin-inline: auto;
}8. Make the page usable
Before adding decorative details, check these basics:
- Does the page have a useful title and a logical heading structure?
- Do links and buttons say what they do?
- Can you see keyboard focus when you tab through the page?
- Is there enough contrast between text and its background?
- Do images fit their containers without distortion?
- Does the page work when zoomed in?
- Is there any horizontal scrolling on a narrow screen?
A simple visible focus style can help keyboard users see where they are:
a:focus-visible,
button:focus-visible {
outline: 3px solid #f97316;
outline-offset: 3px;
}9. Build and test in stages
Work in short steps, checking the page in your browser after each major change:
- Add the semantic HTML and your page copy.
- Set the base type, colours, box sizing and spacing.
- Style the header and introduction.
- Build the lesson cards with Grid.
- Add a Flexbox component and one positioned detail.
- Adjust the design for narrower screens.
- Test narrow, intermediate and wide widths.
- Check keyboard focus, zoom, images and overflow.
- Tidy repeated CSS and save your final version.
Exercises
Try these before opening the answer key.
1. In your own words, explain why the universal box-sizing rule is useful.
2. Identify one part of your page that suits Flexbox and one that suits Grid. Explain why each is a good fit.
3. Add a badge to one lesson card. What needs to be true of the card for the badge to position itself relative to it?
4. Make your main heading scale with the viewport, but keep a sensible minimum and maximum size.
5. Check your page at three widths: narrow, intermediate and wide. Record one issue you find and the change you make to fix it.
6. Use only the keyboard to navigate the page. Can you see which link or button is focused?
7. Finish the project. Complete the acceptance checklist below, then use the CSV rubric to review your page.
Acceptance checklist
- The file opens directly in a browser.
- The page has a course title, introduction and lesson content.
- The page uses Grid and Flexbox for appropriate layout tasks.
- Any positioned detail is anchored deliberately and does not obscure content.
- The layout adapts to narrow, intermediate and wide widths.
- Images stay within their containers and keep their proportions.
- Headings, links and controls are clear and meaningful.
- Keyboard focus is visible.
- There is no unexplained horizontal overflow.
- The CSS is readable enough to update later.
Key takeaways
- Start with the page structure and content before polishing the visual details.
- Use Grid for two-dimensional layout and Flexbox for one-dimensional components.
- Responsive design includes fluid sizing and testing between breakpoints.
- Positioning is most predictable when you deliberately establish the anchor.
- Review accessibility and usability alongside appearance.
Quick check 1: With border-box, an element’s declared width includes its padding and border. That makes the final box size easier to reason about.
Exercise 1: It makes the declared width include padding and border, rather than adding them outside the width.
Exercise 2: Answers vary. A navigation bar is often a good Flexbox use because it arranges items along one line. A lesson-card collection is often a good Grid use because it forms rows and columns.
Exercise 3: The card should establish a containing block, commonly with position: relative. The badge can then use position: absolute and inset values such as top and right.
Exercise 4: One valid approach is:
h1 {
font-size: clamp(2rem, 5vw, 4rem);
}Exercise 5: Answers vary. A strong review names a specific issue—for example, cards becoming cramped—and describes a targeted change, such as allowing the grid to wrap or adjusting a breakpoint.
Exercise 6: Use the Tab key to move between links and buttons. If the focus indicator is hard to see, add or improve a :focus-visible style.
Exercise 7: The project is ready for self-review when its structure is understandable, its layout adapts, and its controls remain usable. The rubric is a guide for finding improvements, not a demand to add extra effects.
You’ve now completed the CSS from Scratch course. You can paste your index.html here if you’d like a review against the project checklist.