1/20
Looks like no tags are added yet.
CSS Rules
Rules: selector { property: value; }.
CSS properties control:
Typography - color, font family, size, weight, and style.
Spacing- margin, padding, and gaps.
Layout - display, position, flexbox, and grid.
Surfaces - backgrounds, borders, radius, and shadows.
Interaction - transitions, transforms, and animations.
Classes
Classes are reusable (.card)
A reusable grouping attribute.
Many elements (even different element type) can share a class.
An element can have multiple classes.
ID
IDs are unique (#card)
A unique identifier for one element.
Each ID value must be unique within the document.
An element can have one ID.
Type selectors
type selectors target tags (p)
CSS Selectors
A B means descendant
A > B direct child
A + B the immediately following sibling
A, B groups matches (Matches both all a elements and all b elements independently)
CSS Specificity Hierarchy
Inline styles > IDs (#id) > Classes / Attributes / Pseudo-classes (.class, [attr], :hover) > Types / Pseudo-elements (div, ::before)
A directly specified child property overrides inherited parent styling.
Block and Inline
Block boxes start on a new line and expand across available width whereas inline boxes flow within a line and are only as wide as their content.
Box model (inside → outside)
content, padding, border, margin
Margins and padding are transparent
content-box vs. border-box
content-box (width behavior): The width property applies strictly to the inner content area, causing padding and borders to add onto the outside and increase the rendered box size.
border-box (width behavior): The width property includes content, padding, and borders inside that exact measurement, shrinking the inner content area to make room.
Rendered Outer Width: Under content-box, rendered width equals width + L/R padding + L/R border, whereas under border-box, rendered width equals the specified width.
Margins in Both Models: Margins always sit outside the rendered border edge and add to total occupied horizontal space in both content-box and border-box.
Flex Container
Flex container is the element with display:flex
only its direct children become flex items.
Flex-direction
flex-direction sets the main axis
Row is the default, row reverse reverse their order along that axis.
Column stacks items vertically. column reverse reverse the vertical order.
justify-content distributes free space along main axis
align-items works on the cross axis;
flex-wrap allows new lines for flex objects;
order changes visual order but not DOM/keyboard order
Grid
Flexbox follows one main axis whereas Grid establishes a two-dimensional coordinate system.
Grid container
The parent with display:grid or display:inline-grid
Grid items
The children of the Grid container
Container properties
Define tracks, gaps, flow, and default alignment
Flexible Shares
(fr): grid-template-columns: 1fr 2fr; splits available space into proportional shares (1 part and 2 parts).
Track Spacing
(gap): gap sets uniform spacing directly between grid rows and columns without needing margins.
Spanning Tracks
grid-column: 1 / 3; makes an item stretch from grid line 1 to grid line 3 (spanning two columns).
Media Queries
(@media): Media queries conditionally apply CSS rules when the viewport reaches specific widths or breakpoints.
Fluid Sizing & Images
Using percentage-based fluid widths alongside max-width: 100%; on images prevents content from overflowing smaller screens.
Viewport Meta Tag
Mobile pages require <meta name="viewport" content="width=device-width, initial-scale=1"> in the <head> so mobile browsers match the CSS viewport to the actual screen width.