Lesson 114 +5 XP

CSS Property Reference

CSS Property Reference

The complete list of practical CSS properties, grouped by job. Bookmark this page!

Text

PropertyWhat it setsExample
colorText colorcolor: red;
font-familyTypefacefont-family: Arial;
font-sizeText sizefont-size: 16px;
font-weightBoldnessfont-weight: bold;
font-styleItalic or normalfont-style: italic;
font-variantSmall capsfont-variant: small-caps;
line-heightSpace between linesline-height: 1.5;
letter-spacingSpace between lettersletter-spacing: 1px;
word-spacingSpace between wordsword-spacing: 4px;
text-alignLeft/right/center/justifytext-align: center;
text-decorationUnderline etc.text-decoration: none;
text-transformUpper/lower/capitalizetext-transform: uppercase;
text-shadowShadow on texttext-shadow: 1px 1px 2px;
white-spaceHow spaces/newlines behavewhite-space: nowrap;
text-overflowEllipsis on overflowtext-overflow: ellipsis;
fontShorthand for font propsfont: 16px Arial, sans-serif;

Background

PropertyWhat it setsExample
background-colorSolid background colorbackground-color: #fff;
background-imageBackground picturebackground-image: url(img.png);
background-repeatTiling behaviorbackground-repeat: no-repeat;
background-positionImage positionbackground-position: center;
background-sizeImage size / coverbackground-size: cover;
background-attachmentScrolls or fixedbackground-attachment: fixed;
backgroundShorthandbackground: #fff url(x) no-repeat;

Box

PropertyWhat it setsExample
widthContent widthwidth: 200px;
heightContent heightheight: 100px;
max-widthWidth capmax-width: 600px;
min-widthWidth floormin-width: 150px;
paddingInside spacingpadding: 10px;
marginOutside spacingmargin: 0 auto;
borderFrameborder: 1px solid black;
border-radiusRounded cornersborder-radius: 8px;
outlineFocus ring-ish borderoutline: 3px solid blue;
box-shadowDrop shadowbox-shadow: 0 2px 6px rgba(0,0,0,.3);
box-sizingborder-box or content-boxbox-sizing: border-box;
overflowClip/scroll contentoverflow: auto;
opacityWhole-element transparencyopacity: 0.5;

Layout

PropertyWhat it setsExample
displayblock/inline/flex/grid/nonedisplay: flex;
positionstatic/relative/absolute...position: relative;
top/right/bottom/leftOffsetstop: 20px;
z-indexStacking orderz-index: 10;
floatFloats an elementfloat: left;
clearStops float adjacencyclear: both;
visibilityHidden keeps spacevisibility: hidden;

Flexbox

PropertyWhat it setsExample
flex-directionRow or columnflex-direction: column;
flex-wrapAllow wrappingflex-wrap: wrap;
justify-contentMain-axis alignmentjustify-content: center;
align-itemsCross-axis alignmentalign-items: center;
align-contentMulti-line distributionalign-content: space-between;
flexGrow/shrink/basis shorthandflex: 1;
align-selfItem-level alignalign-self: flex-end;
orderVisual order of itemsorder: 2;

Grid

PropertyWhat it setsExample
grid-template-columnsColumn tracksgrid-template-columns: 1fr 1fr;
grid-template-rowsRow tracksgrid-template-rows: auto 100px;
grid-template-areasNamed areasgrid-template-areas: "header header";
grid-columnColumn placementgrid-column: 1 / 3;
grid-rowRow placementgrid-row: span 2;
gapTrack spacinggap: 12px;
justify-itemsInline (horizontal) alignmentjustify-items: center;
align-itemsBlock (vertical) alignmentalign-items: start;

Effects & animation

PropertyWhat it setsExample
transformRotate/scale/translatetransform: rotate(45deg);
transform-originPivot pointtransform-origin: left;
transitionSmooth state changestransition: all .3s ease;
animationKeyframe animationsanimation: spin 2s infinite;
filterImage/UI effectsfilter: blur(4px);
text-shadowText depthtext-shadow: 1px 1px hotpink;
box-shadowBox depthbox-shadow: 0 4px 8px black;
cursorPointer stylecursor: pointer;
clip-pathVisually clip the boxclip-path: circle(50%);
object-fitHow img/video fills boxobject-fit: cover;

Interactivity & misc

PropertyWhat it setsExample
cursorMouse cursor shapecursor: grab;
pointer-eventsAccept clicks?pointer-events: none;
user-selectAllow text selectionuser-select: none;
resizeAllow user resizingresize: both;
accent-colorCheckbox/radio accentaccent-color: #04aa6d;
scroll-behaviorSmooth scroll jumpscroll-behavior: smooth;

Shared shorthands to remember

  • margin: top right bottom left;
  • padding: top right bottom left;
  • border: width style color;
  • font: style variant weight size/line-height family;
  • flex: grow shrink basis;
  • animation: name duration timing delay iteration direction fill;

TL;DR

  • This is your CSS dictionary: text, box, layout, grid, flex, effects.
  • Remember the shorthand orders, they come up daily.
  • Bookmark this page for any property you forget.