Tutorials › CSS Tutorial › CSS Property Reference

CSS Property Reference

10 min read · Lesson 20 of 21

This page lists the CSS properties used most often, grouped by topic. Use it as a quick reminder while you build. Each group links back to the lesson that explains it in detail.

Colour and background

See Colours and Backgrounds.

PropertyWhat it doesExample value
colortext colour#333, rgb(0 0 0)
background-colorsolid fill behind the element#f5f5f5
background-imageimage or gradient behind the elementlinear-gradient(red, blue)
background-sizehow big the background image iscover, contain
background-positionwhere the background image sitscenter, top right
background-repeatwhether the image tilesno-repeat
backgroundshorthand for all background properties#000 url(a.jpg) center / cover no-repeat
opacitytransparency of the whole element0.5

Borders and shadows

See Borders.

PropertyWhat it doesExample value
borderwidth, style and colour of all four sides1px solid #ccc
border-top / -right / -bottom / -leftone side only3px solid gold
border-radiusrounds the corners8px, 50%
outlineline outside the border that takes no space2px solid orange
box-shadowshadow around the box0 2px 6px rgb(0 0 0 / 0.2)

Box model and sizing

See The Box Model and Units.

PropertyWhat it doesExample value
width / heightsize of the box300px, 50%
max-width / min-widthupper or lower width limit1100px
max-height / min-heightupper or lower height limit100vh
paddingspace inside the border10px 20px
marginspace outside the border0 auto
box-sizingwhether width includes padding and borderborder-box
overflowwhat happens to content that does not fithidden, auto, scroll
aspect-ratiokeeps a width-to-height ratio16 / 9

Text and fonts

See Text and Fonts.

PropertyWhat it doesExample value
font-familytypeface, with fallbacks"Poppins", Arial, sans-serif
font-sizesize of the text1rem, 18px
font-weightthickness of the letters400, bold
font-styleitalic or normalitalic
fontshorthand for font propertiesitalic 700 18px/1.5 Arial
line-heightspace between lines1.6
text-alignhorizontal alignmentcenter
text-decorationunderline, line-through or nonenone
text-transformletter caseuppercase
letter-spacingspace between letters1px
text-shadowshadow behind text1px 1px 2px black
white-spacehow spaces and line breaks are handlednowrap
list-stylebullet type for listsnone, square

Display and positioning

See Display and Visibility and Position.

PropertyWhat it doesExample value
displayhow the box takes part in layoutblock, inline-block, flex, grid, none
visibilityhides the element but keeps its spacehidden
positionpositioning methodrelative, absolute, fixed, sticky
top / right / bottom / leftoffsets for positioned elements0, 20px
z-indexstacking order of overlapping elements10
floatpushes an element to one side so text wraps around itleft
cursormouse pointer shapepointer

Flexbox

See Flexbox Container and Flexbox Items.

PropertyWhat it doesExample value
flex-directiondirection of the main axisrow, column
flex-wraplets items wrap onto new lineswrap
justify-contentspacing along the main axisspace-between, center
align-itemsalignment on the cross axiscenter, stretch
align-contentspacing of wrapped linesflex-start
gapspace between items16px
flexgrow, shrink and basis of an item1, 0 0 200px
align-selfcross-axis alignment for one itemflex-end
ordervisual order of an item-1

Grid

See Grid.

PropertyWhat it doesExample value
grid-template-columnscolumn sizesrepeat(3, 1fr)
grid-template-rowsrow sizesauto 1fr auto
grid-template-areasnamed layout map"header header" "side main"
grid-areaplaces an item in a named areaheader
grid-column / grid-rowwhich lines an item spans1 / -1, span 2
place-itemsaligns all items in their cellscenter

Effects and motion

See Transitions and Animations.

PropertyWhat it doesExample value
transitionanimates property changesall 0.3s ease
transformmoves, scales or rotatestranslateY(-5px) scale(1.05)
animationruns a @keyframes animationspin 1s linear infinite
filtervisual effects such as blur or greyscalegrayscale(100%)

At-rules and functions

ItemWhat it doesExample
@mediaapplies CSS under conditions@media (min-width: 768px)
@keyframesdefines animation steps@keyframes fade { ... }
@importloads another stylesheet@import url("base.css");
var()reads a custom property (see CSS Variables)var(--brand)
calc()does maths with mixed unitscalc(100% - 40px)
clamp()a value between a minimum and maximumclamp(1rem, 4vw, 2rem)
min() / max()picks the smaller or larger valuemin(90%, 1000px)

Selector cheat sheet

See Syntax and Selectors, Pseudo-classes and Pseudo-elements and Combinators and Specificity.

SelectorSelects
*every element
pall paragraphs
.cardelements with class card
#topthe element with id top
a[target]links with a target attribute
nav alinks anywhere inside nav
ul > lidirect children only
h2 + pthe paragraph right after an h2
a:hovera link under the mouse
li:nth-child(odd)odd list items
p::first-linethe first line of each paragraph
Sign in or create a free account to track progress, earn XP, badges and a certificate.