🖼️CSS
styling a website using a design language
Cascading style sheets (CSS) allows us to "style" a website and its components, in terms of its:
Backgrounds
Spacing (margins, borders, paddings)
Displaying
Positioning
Layering ("bring-to-front")
Visibility (hiding/showing)
Transforming (rotating/flipping)
Animating
Typography
Example
CSS looks like this:
Selectors
A selector refers to an element in an HTML document (e.g. h1
) and has a set of curly braces {}
:
Declarations
A declaration consists of:
Declarations lie inside a declaration block, i.e. inside the curly braces {}
, e.g.:
A group of selectors with declarations can form a stylesheet (the "SS" in CSS!)
Whereas:
HTML provides a rough order and arrangement of elements of a webpage...
...CSS supplies design details with pixel-precision values!
Cascades
The "C" in CSS refers to "cascading" and, in this context, that simply means that any styling instruction/rule that happens further down the stylesheet, becomes the new rule!
For example, in an HTML document like this:
The text will appear red if the CSS works like this:
The second instruction overrides the first because it comes later in the stylesheet!
Last updated