Chapter practice task
Task: Give your HTML portfolio its first stylesheet
- Create a
cssfolder and astyle.cssfile inside it, then link it from yourindex.html. - Set a background color and a text color on the
bodyusing HSL. - Style your
h1, paragraphs and links with element selectors. - Add one class, like
.intro, and give it a different color and font size inrem. - Open the page on your phone (or DevTools mobile view) and check everything is readable.
By the end of this chapter
- You can add CSS in three ways and know which one to use
- You can target elements with element, class and ID selectors
- You can choose colors in hex, RGB or HSL and pick the right unit for sizes
Quick answers for this chapter
Where should I put my CSS?
In a separate .css file linked in the <head>. It keeps your HTML clean and one file can style every page.
Is CSS a programming language?
Not really. It’s a stylesheet language: it describes how things look, but it doesn’t have logic like JavaScript.
Does CSS work the same in every browser?
Almost. Modern browsers follow the same rules for nearly everything a beginner uses.