Skip to content
UPEEC

CSS Fundamentals

Selectors, the cascade, the box model, colours, units, typography and the core properties.

Beginner
Comments 0

This is an overview — pick a sub-topic below.

Sub-topics (27)

CSS Selectors

Patterns that choose which elements a rule styles: type (`p`), class (`.card`), id (`#main`), universal (`*`), groups (`h1, h2`).

Beginner♥ 0🔖 0💬 0

Specificity

When rules conflict, the more specific selector wins: inline > id > class/attribute/pseudo-class > type.

Easy♥ 0🔖 0💬 0

The Cascade

How browsers resolve conflicting declarations: origin and importance → cascade layers → specificity → source order.

Easy♥ 0🔖 0💬 0

CSS Inheritance

Some properties (color, font, line-height) pass from parent to children; others (margin, border) don't.

Beginner♥ 0🔖 0💬 0

Box Model

Every element is a box: content + padding + border + margin.

Beginner♥ 0🔖 0💬 0

Display

Controls how a box behaves: `block`, `inline`, `inline-block`, `flex`, `grid`, `none`, `contents`.

Beginner♥ 0🔖 0💬 0

Positioning

`static` (default), `relative`, `absolute`, `fixed` and `sticky` with `top`/`right`/`bottom`/`left`.

Easy♥ 0🔖 0💬 0

Margins

Space outside the border. Vertical margins between blocks collapse into the larger one.

Beginner♥ 0🔖 0💬 0

Padding

Space inside the border, around the content; takes the element's background.

Beginner♥ 0🔖 0💬 0

Borders

Lines around the padding box: width, style and colour, plus `border-radius` for rounded corners.

Beginner♥ 0🔖 0💬 0

CSS Colors

Named colours, hex, `rgb()`, `hsl()` and modern `oklch()` with optional alpha.

Beginner♥ 0🔖 0💬 0

CSS Units

Absolute (`px`) and relative units: `em` (parent font size), `rem` (root font size), `%`, `vw`/`vh`, `ch`, `fr`.

Beginner♥ 0🔖 0💬 0

Typography

Font size, line height, weight, letter spacing and measure (line length) make text readable.

Beginner♥ 0🔖 0💬 0

Fonts

Load and use font families with fallbacks.

Easy♥ 0🔖 0💬 0

Backgrounds

`background-color`, `background-image`, `size`, `position`, `repeat` and multiple layers.

Beginner♥ 0🔖 0💬 0

Gradients

Smooth colour transitions: `linear-gradient`, `radial-gradient`, `conic-gradient`.

Easy♥ 0🔖 0💬 0

Shadows

`box-shadow` for elements and `text-shadow` for text — depth and emphasis.

Beginner♥ 0🔖 0💬 0

Overflow

What happens when content is bigger than its box: `visible`, `hidden`, `scroll`, `auto`, `clip`.

Easy♥ 0🔖 0💬 0

Visibility

`visibility: hidden` hides an element but keeps its space; `display: none` removes it; `opacity: 0` keeps it interactive.

Beginner♥ 0🔖 0💬 0

Z-Index

Controls stacking order of positioned elements within a stacking context.

Easy♥ 0🔖 0💬 0

Pseudo-Classes

Select elements by state or position: `:hover`, `:focus-visible`, `:checked`, `:disabled`, `:first-child`, `:nth-child(2n)`, `:not()`, `:is()`, `:has()`.

Easy♥ 0🔖 0💬 0

Pseudo-Elements

Style parts of an element: `::before`, `::after`, `::first-line`, `::placeholder`, `::selection`, `::marker`.

Easy♥ 0🔖 0💬 0

Attribute Selectors

Match elements by attributes: `[disabled]`, `[type="email"]`, `[href^="https"]`, `[href$=".pdf"]`, `[class*="icon"]`.

Easy♥ 0🔖 0💬 0

Combinators

Relationships between selectors: descendant (space), child (`>`), next sibling (`+`), subsequent siblings (`~`).

Easy♥ 0🔖 0💬 0

CSS Functions

Built-in functions: `calc()`, `min()`, `max()`, `clamp()`, `var()`, `color-mix()`, `url()`, transforms and gradients.

Easy♥ 0🔖 0💬 0

At-Rules

Instructions starting with `@`: `@media`, `@container`, `@supports`, `@font-face`, `@keyframes`, `@import`, `@layer`, `@property`.

Easy♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.