CSS Course¶
HTML gives a page structure and meaning. CSS controls how that structure looks: colour, type, spacing, and layout.
This track follows the HTML course. You will use the same index.html file and add a separate stylesheet.
Before you start¶
You should be able to build a simple HTML page with headings, paragraphs, links, and images. If not, work through the HTML course first.
You need a folder containing an HTML file and a CSS file. Keep them in the same folder so the path is easy to manage.
Linking a stylesheet¶
Add this line inside <head>:
The href must match the CSS file name exactly. If the file is in a folder, include the folder in the path:
If the styles do not appear, check the file name and path first. That is the most common mistake.
How to use this track¶
- Type the examples instead of copying them.
- Change one value at a time and reload the browser.
- Use the browser's developer tools to inspect the element and see which CSS rules apply.
- Keep a small project open while you read. The practice chapters make more sense when you have a page to style.
Chapters¶
The chapter numbers are the recommended order. The groups below match that order.
Foundations¶
- What is CSS?: rules, declarations, and where to put CSS.
- Box Model: content, padding, border, margin, and
box-sizing. - Selectors: type, class, id, attribute, and combinators.
- Nesting: write related selectors inside one rule.
How CSS is applied¶
- The Cascade: source order, origins, and importance.
- Specificity: which selector wins.
- Inheritance: which properties flow from parent to child.
Values and colour¶
Layout¶
- Layout: normal flow and positioning.
- Flexbox: one-dimensional layout.
- Grid: two-dimensional layout.
- Logical Properties:
inlineandblockinstead of left and right.
Reusable values and spacing¶
- Custom Properties: reusable values with
var(). - Spacing: padding, margin, gap, and a spacing scale.
Appearance¶
- Pseudo-elements:
::before,::after, and text fragments. - Pseudo-classes:
:hover,:focus-visible, and structural states. - Borders: width, style, colour, and radius.
- Shadows:
box-shadowandtext-shadow.
Typography and responsive design¶
- Typography: fonts, sizes, and readable text.
- Responsive: fluid layouts and media queries.
Finishing¶
- Functions:
calc(),min(),max(), andclamp(). - Practice: Build a Page: put the whole track together.
What you should be able to do at the end¶
- Link a stylesheet and explain why a rule is not applying.
- Use classes and a small set of reusable values.
- Build a page layout with flexbox or grid.
- Make text readable and colour contrast accessible.
- Adjust a page for narrow screens without duplicating all your CSS.
CSS describes presentation. HTML still describes meaning. Keep that split and both languages stay simpler.