What is CSS?
CSS styles a web page. A rule is a selector, a property and a value, and a link tag joins the style.css file to the HTML page.
Try it
- Colour picker – Mix a colour from red, green and blue and see its rgb(), its hex code and the bits of each channel.
Transcript
C S S is the language that describes how a page looks: colors, fonts and sizes. H T M L is the structure. C S S is the style.
A C S S rule has three parts. The selector says which elements to style. Inside curly brackets, a property says what to change, and a value says how.
This rule says: every h one gets the color blue. Add a rule for p, and every paragraph gets a bigger font. One rule styles every matching element.
Put your rules in a file called style dot c s s, and join it to the page with a link tag in the head. Now the page and its style are connected.
Remember: C S S styles a page. A rule is a selector, a property and a value, and a link tag joins the C S S file to the H T M L.
More in this series
1:2116What is HTML?
HTML describes the content of a web page with elements: an opening tag, content and a closing tag. The page skeleton, head and body, and nesting.
1:3517Links, images and lists
Attributes add information to a tag: href for links, src and alt for images. How a relative path finds a file, and how ul, ol and li make lists.
1:1319The box model
Every element is a box with four layers: content, padding, border and margin. How each one is set with CSS, and what changes when you change a number.
1:2220DevTools: inspect and fix
Right click and Inspect: the Elements tab, the Styles panel, live edits that vanish on refresh, and the Console for finding errors.
1:1621Classes and ids
A class is a name many elements can share, an id belongs to one element. The dot and hash selectors, and div and span as plain containers.
1:1622Flexbox
Line up elements with display: flex. Flex container and flex items, justify-content, align-items, gap, flex-wrap and flex-direction.
1:1823Responsive design
Make a page fit any screen: the viewport meta tag, flexible sizes with percentages and max-width, and a media query that stacks the cards on narrow screens.