CSS Cheat Sheet
Get up to speed with CSS fast. A comprehensive CSS cheat sheet for web developers.
Box Model
width
: Specifies the width of an elementheight
: Specifies the height of an elementpadding
: Specifies the padding inside an elementborder
: Specifies a border around an elementmargin
: Specifies the margin outside an element
Text
font-family
: Specifies the font for textfont-size
: Specifies the size of textcolor
: Specifies the color of texttext-align
: Specifies the horizontal alignment of texttext-decoration
: Specifies the text decoration (underline, overline, line-through)text-indent
: Specifies the indentation of the first line of text in a blocktext-shadow
: Specifies a shadow for texttext-transform
: Specifies the capitalization of text (none, capitalize, uppercase, lowercase)vertical-align
: Specifies the vertical alignment of an inline-level element in a line box (baseline, text-top, middle, text-bottom, super, sub)white-space
: Specifies how white space inside an element should be handled (normal, pre, nowrap, pre-wrap, pre-line)
Background
background-color
: Specifies the background color of an elementbackground-image
: Specifies a background image for an elementbackground-repeat
: Specifies if a background image should repeat or notbackground-attachment
: Specifies if a background image is fixed or scrolls with the rest of the page
Display
display
: Specifies how an element should be displayed (inline, block, inline-block, none)visibility
: Specifies if an element is visible or hidden
Flexbox
display: flex
: Specifies that an element is a flex containerflex-direction
: Specifies the direction of the flex items (row, row-reverse, column, column-reverse)justify-content
: Specifies how the flex items are aligned along the main axis (flex-start, flex-end, center, space-between, space-around)align-items
: Specifies how the flex items are aligned along the cross axis (flex-start, flex-end, center, baseline, stretch)flex-wrap
: Specifies whether flex items should wrap or not (nowrap, wrap, wrap-reverse)flex-flow
: Shorthand property forflex-direction
andflex-wrap
justify-content
: Specifies the alignment of flex items along the main axis (flex-start, flex-end, center, space-between, space-around)align-content
: Specifies the alignment of a flex container's lines within the flex container when there is extra space along the cross axis (flex-start, flex-end, center, space-between, space-around, stretch)
Positioning
position
: Specifies the type of positioning for an element (static, relative, absolute, fixed)top
: Specifies the distance of an element from the top of its containing elementbottom
: Specifies the distance of an element from the bottom of its containing elementleft
: Specifies the distance of an element from the left of its containing elementright
: Specifies the distance of an element from the right of its containing element
Transforms
transform
: Specifies the transformation to be applied to an elementtranslate
: Specifies the translation (movement) of an element in the x and y axisrotate
: Specifies the rotation of an elementscale
: Specifies the scaling of an element in the x and y axisskew
: Specifies the skewing of an element in the x and y axis
Transitions
transition
: Specifies the transition effect for an elementtransition-property
: Specifies the CSS property to which the transition effect should be appliedtransition-duration
: Specifies the duration of the transition effecttransition-timing-function
: Specifies the speed curve of the transition effecttransition-delay
: Specifies the delay before the transition effect starts
Animations
animation
: Specifies the animation for an elementanimation-name
: Specifies the name of the @keyframes animationanimation-duration
: Specifies the duration of the animationanimation-timing-function
: Specifies the speed curve of the animationanimation-delay
: Specifies the delay before the animation startsanimation-iteration-count
: Specifies the number of times the animation should runanimation-direction
: Specifies the direction of the animation (normal, reverse, alternate, alternate-reverse)
Border
border-width
: Specifies the width of an element's borderborder-style
: Specifies the style of an element's border (solid, dotted, dashed, double, groove, ridge, inset, outset)border-color
: Specifies the color of an element's borderborder-radius
: Specifies the rounding of an element's corners
Shadows
box-shadow
: Specifies a shadow for an elementtext-shadow
: Specifies a shadow for text
Typography
line-height
: Specifies the height of a line of textletter-spacing
: Specifies the spacing between characters in textword-spacing
: Specifies the spacing between words in texttext-transform
: Specifies the capitalization of text (none, capitalize, uppercase, lowercase)
Lists
list-style
: Specifies the style of a list (disc, circle, square, none)list-style-position
: Specifies the position of the list marker (inside, outside)list-style-image
: Specifies an image as the list marker
Tables
border-collapse
: Specifies whether table borders should be collapsed into a single border or separatedborder-spacing
: Specifies the distance between the borders of adjacent cellscaption-side
: Specifies the position of the table caption (top, bottom)empty-cells
: Specifies whether or not to display borders and backgrounds for empty cells in a table
Grid
display: grid
: Specifies that an element should be displayed as a grid containergrid-template-columns
: Specifies the size and number of columns in a gridgrid-template-rows
: Specifies the size and number of rows in a gridgrid-template-areas
: Specifies named grid areasgrid-column-gap
: Specifies the size of the gap between columns in a gridgrid-row-gap
: Specifies the size of the gap between rows in a gridgrid-gap
: Shorthand property forgrid-column-gap
andgrid-row-gap
justify-items
: Specifies the alignment of grid items along the row axis (start, end, center, stretch)align-items
: Specifies the alignment of grid items along the column axis (start, end, center, stretch)justify-content
: Specifies the alignment of grid items along the row axis within the grid area (start, end, center space-between, space-around)align-content
: Specifies the alignment of grid items along the column axis within the grid area (start, end, center, space-between, space-around, stretch)
Backgrounds
background
: Specifies all the background-related properties in one line of codebackground-color
: Specifies the background color of an elementbackground-image
: Specifies an image as the background of an elementbackground-repeat
: Specifies if and how a background image should repeat (repeat, repeat-x, repeat-y, no-repeat)background-attachment
: Specifies whether a background image should be fixed or scroll with the rest of the page (scroll, fixed)background-position
: Specifies the position of a background image (top, bottom, left, right, center)
Borders
border
: Specifies a border for an elementborder-width
: Specifies the width of a borderborder-style
: Specifies the style of a border (solid, dotted, dashed, double, groove, ridge, inset, outset)border-color
: Specifies the color of a borderborder-top
,border-right
,border-bottom
,border-left
: Specifies the width, style, and color of a border for each individual side of an elementborder-radius
: Specifies the rounding of the corners of a border
Dimensions
width
: Specifies the width of an elementheight
: Specifies the height of an elementmax-width
: Specifies the maximum width of an elementmax-height
: Specifies the maximum height of an elementmin-width
: Specifies the minimum width of an elementmin-height
: Specifies the minimum height of an element
Margins
margin
: Specifies the margin of an element (can be set for all sides with one property, or for each side individually withmargin-top
,margin-right
,margin-bottom
,margin-left
)auto
: Lets the browser calculate the margin
Padding
padding
: Specifies the padding of an element (can be set for all sides with one property, or for each side individually withpadding-top
,padding-right
,padding-bottom
,padding-left
)
Miscellaneous
opacity
: Specifies the opacity of an elementoverflow
: Specifies what to do if content overflows an element's box (visible, hidden, scroll, auto)cursor
: Specifies the type of cursor to be displayed (default, pointer, auto, etc.)transition
: Specifies the transition effect for an element to change from one style to another (property, duration, timing-function, delay)transform
: Specifies a two-dimensional transformation for an element (scale, rotate, translate, skew)