Students improve the usability and readability of the visual system established in Lesson 5 by controlling the space inside, outside, and around content. The lesson connects whitespace and cognitive load to practical CSS work with the box model, padding, margin, width, and max-width.
Lesson Overview
- Course: Introduction to Web Coding
- Lesson: 6 of 12
- Suggested duration: 60 minutes
- Primary concept: User Experience
- Project milestone: Improve spacing, content width, and readability across the homepage
Learning Objectives
By the end of the lesson, students should be able to:
- Explain how whitespace can reduce cognitive load and make content easier to scan and understand.
- Identify content, padding, border, and margin as parts of the CSS box model.
- Distinguish between space inside an element and space outside an element.
- Use padding, margin, width, and max-width to improve readability and visual organization.
Key Concepts and Vocabulary
- User experience
- Cognitive load
- Whitespace
- Box model
- Content
- Padding
- Border
- Margin
- Width
- Max-width
Materials and Resources
- The student website from Lessons 1 through 5
- A text editor and web browser
- The student’s current
style.css, including the Base CSS and styles added in Lessons 4 and 5 - Several current websites selected by the instructor that use spacing and content width effectively
- User Experience
- Box Model, Size, Margin, and Padding
Prior Knowledge
Students should be comfortable locating and editing CSS rules. Their homepage should already contain a hero, several content sections, a repeated set of boxes, and the typography and color system established in Lesson 5.
Opening Activity
Compare several websites with different amounts of spacing and content density. Ask students which pages feel easier to scan, which feel crowded, and where their eyes naturally separate one idea from another.
Connect the discussion to User Experience. A page is harder to use when visitors must work to separate ideas, read very wide text, or determine which elements belong together. Whitespace can reduce that effort by making relationships and hierarchy clearer.
Direct Instruction
Use the Box Model to explain how CSS controls the space used by every element on the page.
- Content is the text, image, button, or other material inside the element.
- Padding creates space inside the box, between the content and its edge.
- Border defines the edge of the box when one is visible.
- Margin creates space outside the box, separating it from surrounding elements.
- Width sets horizontal size, while max-width allows an element to shrink but prevents it from becoming wider than a chosen limit.
Point out that the Base CSS already uses box-sizing: border-box, so declared widths include padding and borders. It also includes a .wrapper with a maximum width and side padding. Students have been using that wrapper in their sections since Lesson 2, so this is an opportunity to connect familiar code to the box model rather than introducing an unrelated example.
Demonstrate one box from Lesson 4. Increase and decrease its padding, then change the margin between it and nearby elements. Show the difference between changing space inside the component and changing the relationship between components. Then demonstrate how max-width can keep a long text area from stretching too far across a wide screen.
Recommended AI Coding Educator Lessons
The interactive demos and Code Sandbox are useful here because padding and margin are easier to understand when students change values and immediately see where the space appears. A short experiment before editing the project can prevent students from treating the two properties as interchangeable.
Applied Project
Students refine the page they designed in Lesson 5 by making a focused spacing pass. They should improve existing elements rather than redesign the site’s typography or color system.
- Review the three repeated boxes from Lesson 4 and adjust their shared
.boxpadding so the content has enough room inside each component. - Review the margins between headings, paragraphs, images, boxes, and sections and correct areas that feel crowded or disconnected.
- Compare repeated components and make their spacing patterns consistent where they serve the same purpose.
- Check that each heading remains visually connected to the content it introduces rather than appearing equally close to unrelated content.
- Review long text areas and use
max-widthwhere limiting line length would make the content easier to read. - Review the existing
.wrapperand make sure students understand how its maximum width and side padding constrain the page content. It does not need to be changed unless the current project genuinely benefits from a different value. - Review the page from top to bottom and remove spacing that feels excessive or weakens the relationship between related elements.
The goal is not to make every gap identical. Students should use repeated spacing for consistency while still varying space when it helps communicate hierarchy and grouping. The boxes remain stacked for now. Lesson 7 will use Flexbox and Grid to arrange existing content into columns.
Check for Understanding
Students should be able to identify a spacing or width problem on their page, choose the appropriate CSS property, and explain how the change improves readability or organization.
Useful questions include:
- Is this space inside the box or outside the box?
- Why would padding be more appropriate here than margin?
- What is the difference between
widthandmax-width? - What happens to readability when a paragraph becomes very wide?
- How does the spacing show that these elements belong together?
Differentiation and Extensions
Support: Identify one crowded box, one unclear gap between elements, and one overly wide text area for students to improve. Have them explain whether each change requires padding, margin, or max-width before editing the CSS.
Extension: Have students create two spacing treatments for the same section and compare how each version changes grouping, hierarchy, and readability.
If a student cannot tell why a spacing change is affecting the wrong area, the AI Tutor can help them reason through the element’s box model and the specific CSS rule involved. Students should identify the relevant property themselves, make the correction, and verify the result in the browser.
Lesson Outcome
Students finish the lesson with the same visual system from Lesson 5, refined through more intentional padding, margin, content width, and repeated spacing. The homepage should feel less crowded and easier to scan without introducing multi-column layout yet.
Closure
Review the idea that spacing is part of communication, not simply empty space. Preview that Lesson 7 will keep the content, visual system, and spacing work already established while using Flexbox and Grid to change how selected boxes and content groups are arranged.
Teacher Reflection
- Could students distinguish padding from margin in practical situations?
- Could students explain when max-width is more useful than forcing a fixed width?
- Were students able to connect spacing decisions to readability, grouping, and user experience?
- Is the existing content and spacing stable enough for students to begin arranging selected areas into columns in Lesson 7?