Show Menu
Cheatography

CSS Cheat Sheet Cheat Sheet (DRAFT) by

Basic CSS Cheat Sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Font Styles

font-f­amily
Use to declare multiple fonts, if first font doesn't exists other ones will be declared
font-size
Text size (e.g. 30px)
font-w­eight
Text thickness (bold, semibold)
font-style
Style of font (e.g. italic)
font-v­ariant
Variation of font (e.g. small-­caps)

Colors

Predefined Color Names
red, blue, green
RGB (Red, Green, Blue)
Red: rgb(25­5,0,0)
HEX (Hue, Saturated, Lightness)
Red: hsl(0, 100%, 50%)
RGBA (Red, Green, Blue, Alpha)
rgba(255, 0, 0, 0.5) (50% transp­arent red)
HSLA (Hue, Saturated, Lightness, Alpha)
hsla(0, 100%, 50%, 0.5) (50% transp­arent red)
Note:
The 'Alpha' value ranges from 0 (compl­etely transp­arent) to 1 (compl­etely opaque).

Text Styles

text-color
Set the color of text
text-align
Arrang­ement of text (e.g. left, right, center)
text-d­eco­ration
(e.g. underline)
letter­-sp­acing
Spacing between each letter
word-s­pacing
Spacing between each word

Background

backgr­oun­d-color
backgr­oun­d-image
backgr­oun­d-size
backgr­oun­d-p­osition
backgr­oun­d-r­epeat

Transi­tions

transi­tio­n-p­roperty
Specifies CSS property (e.g. width)
transi­tio­n-t­imi­ng-­fun­ction
Specifies speed curve of transition effect
transi­tio­n-delay
Specifies a delay (in seconds) for transition effect.
transi­tio­n-d­uration
Specifies the transition effect duration (in seconds)
 

Table

Table border
boarde­r-c­ollapse
Sets whether the table borders should be collapsed into a single border
Table size
width, height
Sets width and height of table
Table alignment
text-align
Sets the horizontal alignment (left, right, or center) of the content in table

Position

static
Not affected by the top, bottom, left, and right properties
relative
Positioned relative to its normal position
fixed
Always stays in the same place even if the page is scrolled
absolute
Positioned relative to the nearest positioned ancestor
sticky
Positioned based on the user's scroll position

Box Model

Box Model Explan­ation

Content
Place for text and images appear
Padding
Around the content where is transp­arent
Border
Goes around the padding and content
Margins
An area outside the border where is transp­arent

Margins & Padding

Margins
Padding
margin-top
paddin­g-top
margin­-right
paddin­g-right
margin­-left
paddin­g-left
margin­-bottom
paddin­g-b­ottom
EXTRA! (same concept for padding)
margin: 25px 50px 75px;
- top margin is 25px
- right and left margins are 50px
- bottom margin is 75px

margin: 25px 50px;
- top and bottom margins are 25px
- right and left margins are 50px

margin: 25px;
- all margins are 25px

Border Style

border­-style
(e.g. dotted, dashed, solid)
border­-width
Set border width
border­-radius
Set rounded border
border­-color
Set color of border

Display Property Diagram

Display Property

inline
Displays an element as an inline element
block
Displays an element as a block element
inline­-block
Displays an element as an inline­-level block container
flex
Displays an element as a block-­level flex container
grid
Displays an element as a block-­level grid container