CSS Fundamentals: Styling the Web
Learn how CSS works: selectors, the cascade and specificity, the box model, units, colours and text, then modern layout with display, positioning, Flexbox, Grid and responsive design. Finish by building a styled card and a responsive page.
What you will learn
- Write CSS rules and select elements with type, class, id, combinators and pseudo-classes
- Predict which rule wins using specificity, source order and inheritance
- Calculate sizes with the box model, box-sizing and relative units
- Style text and colours accessibly
- Lay out pages with Flexbox, Grid and positioning
- Make a page responsive with media queries
Prerequisites
- HTML basics: elements, attributes and document structure
Learning path
1 Rules, selectors and the cascade
2 Box model, units and text
3 Layout and responsive design
Practical project: Style a responsive profile page
- Create
index.htmlwith a header (name and a navigation with three links), amainwith an introduction, a section with six project cards (title, short text, link) and a footer. - Create
style.css. Start withbox-sizing: border-box, a readable font stack,line-height: 1.6and colours with a contrast ratio of at least 4.5:1 (check with an online contrast checker). - Build the navigation with Flexbox and
gap. Add:hoverand:focus-visiblestyles. - Lay the cards out with Grid: one column on phones, two from 600px, three from 900px (mobile-first, with the viewport meta tag).
- Style the card as in the lesson: border, radius, padding, a button, and a small badge positioned with
position: absoluteinside aposition: relativecard. - Open the browser DevTools, inspect two elements, and write down for each one: the winning selector, its specificity, and the computed box sizes.
- Test at 360px, 768px and 1200px wide and fix anything that overflows.
References
Related courses
HTML Fundamentals: Structure for the Web
Write correct, semantic and accessible HTML: document structure, text, links, images, lists, tables and forms. Learn why structure matters for…
JavaScript Fundamentals
The language of the web, from the ground up: values, types and operators, control flow, functions and arrow functions, arrays with…
Binary & Logic: How Computers Count and Decide
Understand bits and bytes, convert between decimal, binary and hexadecimal, add in binary, and build truth tables for AND, OR, NOT and XOR — the…