Skip to content

Hand-Rolled CSS

You'll write about 40 lines of your own CSS and make your page look like you meant it, with no framework in sight.

About

Most people's first instinct is to grab a framework, and we'd like you to hold off. You'll learn more from 40 lines of CSS you wrote than from 40,000 lines of someone else's, because every line will be one you can explain. Change the font, the spacing, the color and the width, and stop when the page looks deliberate, because that's the whole badge. If the stylesheet ends up under 60 lines, you've done it right.

At a glance

Per requirement
15 XP
Completion bonus
75 XP
Requirements
5
Takes
One evening
Skill level
Novice (never tried it)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own

Requirements

  1. 1
    Link a separate stylesheet file to your page. Create style.css next to index.html and add a link tag in the head. Put one rule in it that's impossible to miss, like body { background: red }, so you know the link works, then take it out again. Take a screenshot of the red page. Photo
  2. 2
    Set a readable font and line length. Pick a font-family stack of system fonts, a font-size of at least 18px, a line-height around 1.5, and a max-width on the main content of 60 to 70 characters, which is about 65ch. Long lines are the reason most homemade pages feel hard to read, so this one change does a lot. Take a screenshot of a paragraph at the new width. Photo
  3. 3
    Style the headings and links on purpose. Give headings their own size, weight and margin, and give links a color and a visible hover state. Keep the underlines unless you add something else that marks them as links, because a link nobody can spot is a link nobody clicks. Take a screenshot showing a heading, a paragraph and a link with the mouse hovering over it. Photo
  4. 4
    Draw the box model on paper, then build it on your page. Sketch margin, border, padding and content for one element. Then add a box to your page where you can see all four: a border, padding inside it, and margin outside it. Take a photo of the sketch held up next to the box on the screen. Photo
  5. 5
    Delete every rule you can't explain. Read your stylesheet from top to bottom and say out loud what each rule does. If you can't, delete it and see what changes, which is usually nothing. Take a screenshot of the final file. Under 60 lines is a good sign. Photo