Front-End Reference

HTML & CSS

A complete, at-a-glance reference covering core markup, styling, layout systems, modern CSS features, accessibility, frameworks and naming conventions.
01HTML Fundamentals
02CSS Fundamentals
03Modern & Advanced CSS
04SVG & Canvas Basics
05Accessibility (ARIA)
06CSS Frameworks
07Class & Div Naming
08Sass / SCSS
PART 01

HTML

1.1 Document Structure

TagDescription
<!DOCTYPE html>Declares the document as HTML5
<html>Root element of the page
<head>Contains metadata (not visible on page)
<title>Sets the browser tab title
<meta charset="UTF-8">Sets character encoding
<meta name="viewport" ...>Makes page responsive on mobile
<meta name="description" ...>SEO description
<link rel="stylesheet">Links an external CSS file
<script src="app.js">Links/embeds JavaScript
<body>Contains all visible page content

1.2 Text & Headings

TagDescription
<h1>–<h6>Headings, largest (h1) to smallest (h6)
<p>Paragraph
<br>Line break (self-closing)
<hr>Horizontal rule / divider
<strong>Bold, semantically important text
<b>Bold, no semantic meaning
<em>Italic, semantically emphasized
<i>Italic, no semantic meaning
<small>Smaller text
<mark>Highlighted text
<del> / <ins>Strikethrough (deleted) / underlined (inserted) text
<sub> / <sup>Subscript / superscript
<code>Inline code snippet
<pre>Preformatted text (preserves whitespace)
<blockquote> / <q>Block quotation / inline short quotation
<abbr title="...">Abbreviation with tooltip
<span>Generic inline container

1.3 Lists

TagDescription
<ul>Unordered (bulleted) list
<ol>Ordered (numbered) list
<li>List item
<dl>Description list
<dt>Term in a description list
<dd>Description / definition of the term

1.4 Links & Navigation

Tag / AttributeDescription
<a href="url">Hyperlink
target="_blank"Opens link in a new tab
rel="noopener noreferrer"Security best practice with target="_blank"
href="#id"Links to an element on the same page
href="mailto:x@y.com"Opens default email client
href="tel:+123"Initiates a phone call on mobile
<nav>Semantic navigation container

1.5 Images & Media

TagDescription
<img src alt>Embeds an image; alt is required for accessibility
<figure> / <figcaption>Groups media with a caption / the caption itself
<picture> / <source>Container for multiple responsive image sources
<audio controls>Embeds audio with playback controls
<video controls>Embeds video with playback controls
<iframe src="...">Embeds another page / document
srcset / sizesAttributes for responsive image resolution switching

1.6 Tables

TagDescription
<table>Table container
<thead> / <tbody> / <tfoot>Groups header / body / footer content
<tr>Table row
<th>Header cell (bold, centered by default)
<td>Standard data cell
colspan="2" / rowspan="2"Merges cells across columns / rows
<caption>Table title / caption

1.7 Forms

Tag / AttributeDescription
<form action method>Form container; method = GET or POST
<input type="text">Single-line text field
type="email / password / number"Validated email / masked / numeric input
type="checkbox / radio"Checkbox toggle / radio button (single choice within a name group)
type="date / file / range"Date picker / file upload / slider control
type="submit / hidden"Submits the form / invisible data sent with it
<textarea>Multi-line text input
<select> / <option>Dropdown container / item inside it
<optgroup label>Groups related <option>s
<label for="id">Accessible label tied to an input's id
<fieldset> / <legend>Groups related controls / caption for the group
<button type=...>Clickable button (submit / button / reset)
placeholder / required / disabled / readonlyHint text / mandatory / disabled / visible-not-editable field
value / nameDefault value / key used when data is submitted
min / max / step / patternConstraints and custom validation pattern
autocomplete / autofocusBrowser autofill behavior / focuses field on load
<datalist>Autocomplete suggestions for an input

1.8 Semantic Layout Elements

TagDescription
<header> / <footer>Introductory / footer content for page or section
<main>The main unique content of the page (one per page)
<section>Thematic grouping of content
<article>Self-contained, independently distributable content
<aside>Tangential content (sidebars, callouts)
<div>Generic block container, no semantic meaning
<details> / <summary>Collapsible widget / its visible heading
<dialog>Native modal / dialog box
<template>Hidden content cloned via JavaScript

1.9 Global Attributes

Work on almost any tag.

AttributeDescription
id / classUnique identifier / space-separated list of CSS classes
style / titleInline CSS / tooltip text on hover
data-*Custom data attribute (e.g. data-user-id="5")
hiddenHides the element
tabindexControls keyboard tab order
contenteditable / draggableMakes content editable / enables drag-and-drop
langLanguage of the element's content
aria-* / roleAccessibility attributes / ARIA role for assistive tech
PART 02

CSS

2.1 Ways to Add CSS

/* Inline:   <p style="color:red;">text</p>            */
/* Internal: <style> p { color:red; } </style> in head  */
/* External: <link rel="stylesheet" href="style.css">   */

2.2 Selectors

SelectorExampleDescription
Universal*Selects everything
TypepSelects all <p> elements
Class.boxSelects elements with class="box"
ID#mainSelects the element with id="main"
Groupingh1, h2Applies rule to multiple selectors
Descendantdiv pAny <p> inside a <div>, any depth
Childdiv > pDirect <p> children of <div> only
Adjacent siblingh1 + pThe <p> immediately after an <h1>
General siblingh1 ~ pAll <p> siblings after an <h1>
Attribute[type="text"]Elements with matching attribute value
Attribute contains[class*="btn"]Attribute value contains a substring
Attribute starts[href^="https"]Attribute value starts with a string
Attribute ends[src$=".png"]Attribute value ends with a string
:hover / :focus / :activea:hoverMouse-over / focused / being-clicked states
:first-child / :last-childli:first-childFirst / last child of its parent
:nth-child(n)li:nth-child(2n)Matches by formula / position (e.g. even items)
:not(x)p:not(.intro)Excludes elements matching x
:checked / :disabledinput:checkedChecked checkboxes/radios / disabled form elements
::before / ::after.box::beforeInserts generated content before / after element
::placeholder / ::first-lineinput::placeholderStyles placeholder text / the first line of a block

2.3 Box Model

PropertyDescription
width / heightSize of the content box
paddingSpace between content and border
borderLine around the padding (width style color)
marginSpace outside the border, between elements
box-sizing: border-boxMakes width/height include padding & border (recommended default)
box-shadow: x y blur spread colorDrop shadow outside (or inset) the box
outlineLine drawn outside the border, doesn't affect layout

2.4 Display & Positioning

Property / ValueDescription
display: block / inline / inline-blockFull-width new line / flows with text / inline but respects box size
display: noneRemoves element from layout entirely
display: flex / gridEnables flexbox / grid layout on children
visibility: hiddenHides element but keeps its space
position: staticDefault; normal document flow
position: relativeOffset relative to its normal position
position: absolutePositioned relative to nearest positioned ancestor
position: fixedPositioned relative to the viewport, stays on scroll
position: stickyToggles between relative and fixed on scroll
top / right / bottom / leftOffsets used with non-static position
z-indexStacking order (higher = on top)
overflow: hidden / scroll / autoControls content that exceeds its box
float / clearLegacy text-wrap around element / stops the wrapping

2.5 Flexbox — Container

PropertyDescription
display: flexActivates flexbox
flex-directionrow | row-reverse | column | column-reverse
justify-contentAligns items on the main axis (flex-start, center, space-between…)
align-itemsAligns items on the cross axis (stretch, center, flex-start…)
align-contentAligns multiple lines when wrapping
flex-wrapnowrap | wrap | wrap-reverse
gapSpace between flex items

2.6 Flexbox — Items

PropertyDescription
flex-grow / flex-shrinkHow much an item grows / shrinks relative to siblings
flex-basisStarting size before growing/shrinking
flex: 1Shorthand — item grows/shrinks to fill space equally
align-selfOverrides align-items for a single item
orderChanges visual order without changing HTML

2.7 Grid — Container

PropertyDescription
display: gridActivates grid layout
grid-template-columnsDefines columns, e.g. 1fr 1fr 1fr or repeat(3, 1fr)
grid-template-rowsDefines row sizes
grid-template-areasNamed layout regions as a text map
gap / row-gap / column-gapSpace between grid cells
justify-items / align-itemsHorizontal / vertical alignment of items in their cell
justify-content / align-contentAligns the whole grid horizontally / vertically

2.8 Grid — Items

PropertyDescription
grid-column: 1 / 3Item spans from column line 1 to 3
grid-row: 1 / 2Item spans from row line 1 to 2
grid-column: span 2Item spans 2 columns
grid-area: namePlaces item into a named template area
justify-self / align-selfAligns a single item within its cell

2.9 Typography

PropertyDescription
font-familyTypeface stack, e.g. "Helvetica", Arial, sans-serif
font-sizeText size (px, em, rem, %)
font-weightBoldness (normal, bold, 100–900)
font-stylenormal | italic | oblique
line-heightSpace between lines of text
letter-spacingSpace between characters
text-alignleft | right | center | justify
text-decorationunderline | line-through | none
text-transformuppercase | lowercase | capitalize
text-shadow: x y blur colorShadow behind text
white-space: nowrapPrevents text from wrapping
text-overflow: ellipsisAdds "…" to clipped overflow text
word-breakControls how words break at line ends

2.10 Colors & Backgrounds

PropertyDescription
colorText color
background-colorElement's background color
background-image: url(...)Sets a background image
background-size: cover / containHow the background image scales
background-position / -repeatPositions / repeats the background image
opacityTransparency of the whole element (0–1)
Color formats#hex, rgb(), rgba(), hsl(), named colors (red)
linear-gradient(dir, c1, c2)Linear color gradient, used with background
radial-gradient(c1, c2)Circular / elliptical gradient

2.11 Borders & Radius

PropertyDescription
border: 1px solid blackShorthand for width, style, color
border-radiusRounds corners (50% makes a circle)
border-top / -right / -bottom / -leftStyle a single side
border-collapse: collapseMerges table borders into one line

2.12 Transitions & Animation

PropertyDescription
transition: property duration timing delayAnimates a property change smoothly
transition-timing-functionease, linear, ease-in-out, cubic-bezier(...)
transform: translate(x,y)Moves an element
transform: scale(n)Resizes an element
transform: rotate(deg) / skew(deg)Rotates / skews an element
@keyframes name {...}Defines an animation sequence
animation: name duration timing countApplies a @keyframes animation
animation-iteration-count: infiniteLoops the animation forever
animation-direction: alternatePlays forward then backward

2.13 Units & Values

UnitDescription
pxAbsolute pixel value
%Relative to the parent element
emRelative to the parent's font size
remRelative to the root (<html>) font size
vw / vh1% of viewport width / height
vmin / vmax1% of the smaller / larger viewport dimension
frFractional unit, used in CSS Grid
autoBrowser calculates the value
calc(100% - 20px)Computes a value from mixed units

2.14 Responsive Design

/* Media query: applies styles under a condition */
@media (max-width: 768px) {
  .container { flex-direction: column; }
}
ConceptDescription
@media (max-width: Npx)Styles apply when viewport ≤ N px (mobile-first breakpoint)
@media (min-width: Npx)Styles apply when viewport ≥ N px
@media (orientation: landscape)Targets landscape / portrait orientation
Mobile-first approachWrite base styles for small screens, then add min-width overrides
<meta name="viewport">Required in HTML for media queries to work correctly on mobile

2.15 CSS Variables (Custom Properties)

:root {
  --main-color: #3498db;
  --spacing: 16px;
}
.box {
  color: var(--main-color);
  padding: var(--spacing);
}

2.16 Pseudo-classes Quick Reference

Pseudo-classDescription
:rootTargets the document's root element (<html>)
:first-of-type / :last-of-typeFirst / last sibling of a specific tag type
:nth-of-type(n)Matches by position among siblings of the same tag
:only-childElement is the only child of its parent
:emptyElement has no children / content
:targetElement matches the URL's current #fragment
:enabled / :disabledForm elements based on interactive state
:valid / :invalidForm elements based on validation state
:placeholder-shownInput currently showing its placeholder

2.17 Common Shorthand Cheatsheet

margin: 10px;                  /* all sides */
margin: 10px 20px;             /* top/bottom  left/right */
margin: 10px 20px 30px 40px;   /* top right bottom left (clockwise) */

font: italic bold 16px/1.5 Arial, sans-serif;
/* style weight size/line-height family */

background: #fff url(bg.png) no-repeat center/cover;

border: 2px dashed red;        /* width style color */
PART 03

Modern & Advanced CSS

3.1 Modern Selectors

SelectorExampleDescription
:is():is(h1, h2, h3){color:navy;}Matches any selector in the list (reduces repetition)
:where():where(h1, h2){margin:0;}Like :is() but has zero specificity
:has()div:has(img)Selects a parent if it contains a matching child ("parent selector")
:focus-visiblebutton:focus-visibleFocus styles only for keyboard navigation, not mouse clicks
:focus-withinform:focus-withinMatches a container if any child inside it has focus
:nth-last-child(n)li:nth-last-child(2)Counts from the end instead of the start
:in-range / :out-of-rangeinput:in-rangeNumber input value within / outside its min/max
:defaultinput:defaultThe default option / checkbox on page load
:read-only / :read-writeMatches editable vs. non-editable form fields

3.2 Useful CSS Functions

FunctionExampleDescription
clamp(min, preferred, max)font-size: clamp(1rem, 2vw, 2rem);Fluid value that never goes below/above the limits
min()width: min(90%, 600px);Uses whichever value is smallest
max()width: max(50%, 300px);Uses whichever value is largest
calc()width: calc(100% - 40px);Math with mixed units
var()color: var(--main, blue);Reads a custom property, with optional fallback
repeat()repeat(3, 1fr)Repeats a grid track pattern
minmax()minmax(100px, 1fr)Sets a min and max size for a grid track
env()env(safe-area-inset-top)Reads device safe-area values (notches, etc.)
attr()content: attr(data-label);Pulls an HTML attribute's value into CSS content

3.3 @-Rules

RuleDescription
@mediaConditional styles based on viewport / device
@supports (display: grid) {...}Applies styles only if the browser supports a feature
@font-face {...}Loads a custom web font
@import url(...)Imports another stylesheet (best avoided for performance)
@keyframesDefines animation steps
@container (min-width: 400px) {...}Styles based on a parent container's size, not the viewport
@layer name {...}Groups styles into cascade layers to control specificity order
@pageStyles for printed pages
@charset "UTF-8";Declares the stylesheet's character encoding

3.4 Grid: Advanced

Property / ValueDescription
subgridChild grid inherits the parent's track sizing
grid-auto-flow: denseFills gaps in the grid automatically
grid-auto-rows / -columnsSizes implicitly-created tracks
place-items: centerShorthand for align-items + justify-items
place-content: centerShorthand for align-content + justify-content
place-self: centerShorthand for align-self + justify-self

3.5 Visual Effects

PropertyDescription
filter: blur(5px)Blurs the element
filter: brightness(1.2)Adjusts brightness
filter: grayscale(100%)Converts to grayscale
filter: drop-shadow(x y blur color)Shadow that follows transparent shapes (unlike box-shadow)
backdrop-filter: blur(10px)Blurs whatever is behind a transparent element (frosted-glass)
mix-blend-modeBlends an element with what's beneath it (multiply, screen, overlay…)
clip-path: circle(50%)Clips the element into a custom shape
aspect-ratio: 16 / 9Forces an element to maintain a width-to-height ratio
object-fit: coverControls how <img>/<video> content fills its box
object-positionPositions the content within object-fit
resize: bothLets the user manually resize an element (e.g. <textarea>)
cursor: pointerChanges the mouse cursor on hover
user-select: nonePrevents text selection
pointer-events: noneElement ignores mouse/touch clicks
scroll-behavior: smoothSmooth scrolling for anchor links
scroll-snap-type / -alignSnaps scrolling to fixed positions (carousels)
will-change: transformHints the browser to optimize for an upcoming animation

3.6 Print Styles

@media print {
  nav, footer, .no-print { display: none; }
  body { color: black; background: white; }
}
PART 04

SVG & Canvas Basics

Tag / PropertyDescription
<svg width height viewBox>Container for scalable vector graphics
<circle cx cy r>Draws a circle
<rect x y width height rx>Draws a rectangle (rx = rounded corners)
<line x1 y1 x2 y2>Draws a straight line
<path d="M...L...">Draws a custom shape/path using path commands
<polygon points="...">Draws a closed multi-point shape
<text x y>Renders text inside SVG
fill / strokeFill color / outline color of an SVG shape
stroke-widthThickness of the outline
<canvas id width height>2D/3D drawing surface controlled via JavaScript
getContext("2d")JS API entry point for drawing on a <canvas>
PART 05

Accessibility (ARIA) Essentials

Attribute / TagDescription
altText alternative for images (use alt="" for decorative images)
aria-label="..."Accessible name when there's no visible text
aria-labelledby="id"Points to another element that labels this one
aria-describedby="id"Points to an element with extra descriptive text
aria-hidden="true"Hides purely decorative content from screen readers
aria-live="polite"Announces dynamic content updates to screen readers
aria-expanded="true/false"State of a collapsible element (accordion, dropdown)
aria-checked / aria-disabledState of a custom checkbox/switch / marks disabled for assistive tech
role="button"Tells assistive tech how to treat a non-semantic element
role="alert"Announces important, time-sensitive messages immediately
tabindex="0" / "-1"Adds to natural tab order / removes but allows programmatic focus
Skip link<a href="#main">Skip to content</a> placed first in <body>
Focus outlineNever fully remove outline on :focus without a visible replacement
PART 06

CSS Frameworks Overview

6.1 Bootstrap — Component / Utility Hybrid

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">

<div class="container">
  <div class="row">
    <div class="col-md-6">Half width on medium+ screens</div>
    <div class="col-md-6">Half width on medium+ screens</div>
  </div>
</div>

<button class="btn btn-primary">Click me</button>
<div class="alert alert-danger">Error message</div>
Class PatternDescription
container / container-fluidResponsive centered wrapper / full-width wrapper
row / col-*12-column grid system
col-md-6, col-lg-4Column width at specific breakpoints
btn btn-primary / -secondary / -dangerPre-styled buttons
d-flex, d-none, d-blockDisplay utilities
justify-content-center, align-items-centerFlex alignment utilities
m-*, p-* (e.g. mt-3, px-2)Margin/padding spacing utilities (0–5 scale)
text-center, text-dangerText alignment / color utilities
card, card-body, card-titleCard component structure
navbar, nav-linkNavigation bar components

6.2 Tailwind CSS — Utility-First

<script src="https://cdn.tailwindcss.com"></script>

<div class="flex items-center justify-between p-4 bg-white shadow-md rounded-lg">
  <h2 class="text-xl font-bold text-gray-800">Title</h2>
  <button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">
    Click me
  </button>
</div>
Class PatternDescription
flex, grid, block, hiddenDisplay utilities
items-center, justify-betweenFlex/grid alignment
p-4, px-2, py-6, m-4Padding/margin (numeric scale, 1 unit = 0.25rem)
text-sm / lg / xl / 2xlFont size scale
font-bold / medium / lightFont weight
bg-{color}-{shade}Background color, e.g. bg-blue-500
text-{color}-{shade}Text color
rounded, rounded-full, rounded-lgBorder radius
shadow, shadow-md, shadow-lgBox shadow presets
hover: focus: active: prefixState-based variants, e.g. hover:bg-blue-600
sm: md: lg: xl: prefixResponsive breakpoint variants
w-full, h-screenWidth/height utilities
gap-4, space-x-2Spacing between flex/grid children
transition, duration-300Animation utilities

6.3 Other Notable Frameworks

FrameworkDescription
BulmaCSS-only, Flexbox-based, no JavaScript required
FoundationEnterprise-grade responsive framework, similar to Bootstrap
Materialize / Material UIImplements Google's Material Design system
Semantic UIHuman-friendly class names (ui button, ui segment)
SkeletonMinimal boilerplate framework for small projects
Pico.cssClassless framework — styles semantic HTML with no classes needed
Chakra UI / Shadcn UIComponent libraries typically paired with React
PART 07

Class & Div Naming Conventions

7.1 BEM (Block, Element, Modifier)

<div class="card card--featured">
  <h2 class="card__title">Title</h2>
  <p class="card__text">Description text</p>
  <button class="card__button card__button--disabled">Buy</button>
</div>
PartSyntaxDescription
Block.cardStandalone, reusable component
Element.card__titleA part of the block (double underscore)
Modifier.card--featuredA variant/state of the block (double hyphen)

7.2 Utility-First Naming (Tailwind-style)

Classes describe a single style rule directly on the element (p-4, text-lg, flex) instead of naming the component. Fast to write, but HTML can get class-heavy.

7.3 Common Semantic / Structural Class Names

Class Name ConventionTypical Use
.container / .wrapperCenters and constrains content width
.row / .colGrid layout structure
.header / .footer / .sidebarLayout landmarks
.btn, .btn-primary, .btn-outlineButton styling variants
.card, .card-header, .card-bodyCard-style UI components
.active, .disabled, .is-open, .is-hiddenJS-toggled state classes
.visually-hidden / .sr-onlyVisually hides content but keeps it for screen readers
.clearfixLegacy fix for collapsing floated containers
.text-*, .bg-*, .mt-*Utility naming pattern (property-value abbreviation)

7.4 Naming Best Practices

PART 08

CSS Preprocessors (Sass / SCSS)

// Variables
$primary-color: #3498db;

// Nesting
.card {
  padding: 1rem;
  &:hover { box-shadow: 0 0 10px rgba(0,0,0,0.2); }
  .title { font-weight: bold; }
}

// Mixins
@mixin flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}
.box { @include flex-center; }

// Partials & imports
@use "variables";

// Functions/operations
.item { width: 100px + 20px; }
FeatureDescription
$variableReusable value (Sass) — native CSS uses --variable instead
&References the parent selector when nesting
@mixin / @includeReusable style blocks
@extendInherits styles from another selector
@if / @elseConditional logic inside stylesheets
@each, @forLoops for generating repetitive styles
@use / @forwardModern module import system (replaces @import)

Quick Tips