HTML Structure
Page Title

Hello World

Common Elements
Text & Headings

Heading 1

...
Heading 6

Paragraph text

Bold Italic

Links & Images
Link text #section">Anchor link Description
Lists
  1. First
Forms
Input Types
Select & Textarea
Semantic HTML
<header>Intro content or nav container
<nav>Navigation links
<main>Primary page content (one per page)
<section>Thematic grouping of content
<article>Self-contained content
<aside>Sidebar or tangential content
<footer>Footer for section or page
<figure>Image/diagram with caption
<figcaption>Caption for
CSS Selectors
Basic Selectors
elementp { } — all

elements

.class.card { } — class selector
#id#main { } — id selector
*Universal selector (all elements)
Combinators
A BDescendant (B inside A)
A > BDirect child only
A + BAdjacent sibling (B right after A)
A ~ BGeneral sibling (B after A)
Pseudo-classes
:hoverMouse over element
:focusElement has focus
:first-childFirst child of parent
:nth-child(n)nth child (2n = even, odd)
Box Model
.box { margin: 10px; /* outside */ border: 1px solid #333; /* edge */ padding: 15px; /* inside */ width: 200px; box-sizing: border-box; /* include pad+border */ }
Shorthand
margin: 10pxAll sides
margin: 10px 20pxTop/bottom | left/right
margin: 10px 20px 15pxTop | left/right | bottom
margin: 10px 20px 15px 5pxTop | right | bottom | left
Flexbox
Container
.flex-container { display: flex; flex-direction: row; /* row | column */ justify-content: center; /* main axis */ align-items: center; /* cross axis */ gap: 10px; flex-wrap: wrap; }
Item Properties
flex: 1Grow to fill available space
flex-grow: 2Grow ratio relative to siblings
flex-shrink: 0Don't shrink below basis
flex-basis: 200pxInitial size before grow/shrink
align-self: flex-endOverride container alignment
order: -1Visual order (default 0)
Grid
Container
.grid { display: grid; grid-template-columns: 1fr 2fr 1fr; grid-template-rows: auto; gap: 10px; }
Item Placement
.item { grid-column: 1 / 3; /* span col 1-2 */ grid-row: 1 / 2; } /* shorthand: repeat, minmax */ grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
Positioning
staticDefault flow (no offset properties)
relativeOffset from normal position
absoluteOffset from nearest positioned ancestor
fixedOffset from viewport (stays on scroll)
stickyRelative until scroll threshold, then fixed
Example
.parent { position: relative; } .child { position: absolute; top: 0; right: 0; /* top-right corner */ }
Media Queries
/* Mobile-first: base styles for small screens */ .container { padding: 10px; } @media (min-width: 768px) { .container { max-width: 720px; } } @media (min-width: 1024px) { .container { max-width: 960px; } }
Common Breakpoints
480pxSmall phones
768pxTablets
1024pxSmall desktops / landscape tablets
1280pxDesktops