CSS Cheatsheet

Named Colors

aliceblue
antiquewhite
aqua
aquamarine
azure
beige
bisque
blanchedalmond
blue
blueviolet
brown
burlywood
cadetblue
chartreuse
chocolate
coral
cornflowerblue
cornsilk
crimson
cyan
darkblue
darkcyan
darkgoldenrod
darkgray
darkgreen
darkkhaki
darkmagenta
darkolivegreen
darkorange
darkorchid
darkred
darksalmon
darkseagreen
darkslateblue
darkslategray
darkturquoise
darkviolet
deeppink
deepskyblue
dimgray
dodgerblue
firebrick
floralwhite
forestgreen
fuchsia
gainsboro
ghostwhite
gold
darkgoldenrod
gray
green
greenyellow
honeydew
hotpink
indianred
indigo
ivory
khaki
lavender
lavenderblush
lawngreen
lemonchiffon
lightblue
lightcoral
lightcyan
lightgoldenrodyellow
lightgreen
lightgrey
lightpink
lightsalmon
lightseagreen
lightskyblue
lightslategray
lightsteelblue
lightyellow
lime
limegreen
linen
magenta
maroon
mediumaquamarine
mediumblue
mediumorchid
mediumpurple
mediumseagreen
mediumslateblue
mediumspringgreen
mediumturquoise
mediumvioletred
midnightblue
mintcream
mistyrose
moccasin
navajowhite
navy
oldlace
olive
olivedrab
orange
orangered
orchid
palegoldenrod
palegreen
paleturquoise
palevioletred
papayawhip
peachpuff
peru
pink
plum
powderblue
purple
red
rosybrown
royalblue
saddlebrown
salmon
sandybrown
seagreen
seashell
sienna
silver
skyblue
slateblue
slategray
snow
springgreen
steelblue
tan
teal
thistle
tomato
turquoise
violet
wheat
white
whitesmoke
yellow
yellowgreen

Gradients

aqua, mediumslateblue

Examples:

background-image: linear-gradient(blue, red);

background-image: linear-gradient(to right, blue, red);

background-image: linear-gradient(to bottom right, blue, red);

background-image: linear-gradient(190deg, blue, red);

background-image: linear-gradient(to right, blue, white, red);

background-image: repeating-linear-gradient(blue, red 10%, yellow 20%);

background-image: radial-gradient(blue, red, yellow);

background-image: radial-gradient(blue 5%, red 15%, yellow 65%);

background-image: radial-gradient(circle, blue, red, yellow);

background-image: repeating-radial-gradient(blue 15%, red 45%);

Shadows

text-shadow

Syntax:

text-shadow: horizontal vertical blur color

Examples:

Text Shadow

text-shadow: 3px 3px 3px black;

Text Shadow

text-shadow: 0 0 6px black;

Text Shadow

text-shadow: 0 0 3px red, 0 0 15px purple;

Text Shadow

text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;

Text Shadow

text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;


box-shadow

box-shadow: 10px 10px 5px grey;

box-shadow: 20px -16px coral;

box-shadow: inset 30px 15px violet;

box-shadow: -10px 0 6px red, 6px 6px white;

Outline

Syntax:

outline: outline-width outline-style outline-color

Examples:

Outline

outline: 3px solid lime;

Outline

outline: 3px dotted lime;

Outline

outline: 3px dashed lime;

Outline

outline: 6px double lime;

Outline

outline: 6px groove lime;

Outline

outline: 6px ridge lime;

Outline

outline: 6px inset lime;

Outline

outline: 6px outset lime;

Outline

outline: 3px solid lime;

outline-offset: -10px;

Border

Syntax:

border: border-width border-style border-color

Examples:

Border

border: 4px solid magenta;

Border

border-top: dashed yellow;

Border

border-right-width: 10px;

Border

border-color: yellow magenta aqua lime;

Border

border-style: dotted;

border-radius: 20px;

list-style-type

Examples:

  • Item 1
  • Item 2
  • Item 3
  • Item 4

list-style-type: circle;

  • Item 1
  • Item 2
  • Item 3
  • Item 4

list-style-type: square;

  • Item 1
  • Item 2
  • Item 3
  • Item 4

list-style-type: disc;

  • Item 1
  • Item 2
  • Item 3
  • Item 4

list-style-type: decimal;

  • Item 1
  • Item 2
  • Item 3
  • Item 4

list-style-type: lower-roman;

  • Item 1
  • Item 2
  • Item 3
  • Item 4

list-style-type: upper-roman;

  • Item 1
  • Item 2
  • Item 3
  • Item 4

list-style-type: lower-greek;

  • Item 1
  • Item 2
  • Item 3
  • Item 4

list-style-type: upper-alpha;

cursor

Syntax:

cursor: value;

Examples(hover):

pointer
help
progress
crosshair
alias
copy
move
not-allowed
grab
zoom-in

Safe Fonts

Arial

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Verdana

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Helvetica

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Tahoma

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Trebuchet MS

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Palatino

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Times New Roman

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Georgia

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Courier New

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Impact

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Brush Script MT

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Comic Sans MS

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

0 1 2 3 4 5 6 7 8 9

Transitions

Syntax:

transition: property duration timing-function delay

Examples(hover):

transition: all 1s;

transition: background-color 1s 1s, width 2s;

Timing Functions

linear

ease-in

ease-out

ease-in-out

Transforms

Syntax:

translate(x-axis, y-axis)

rotate(degrees)

scale(width, height)

skew(x-axis degrees, y-axis degrees)

Examples:

transform: scale(3,2);

transform: skew(30deg, 20deg);

transform: rotate(45deg);

transform: translate(30px, 10px);

Pseudo-Elements

Syntax:

selector::psuedo-element

Pseudo-Elements:

  • ::first-letter
  • ::first-line
  • ::before
  • ::after
  • ::marker
  • ::selection

Examples:

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos natus suscipit quo, libero, nemo quibusdam non alias tempore eaque deleniti.

  • Lorem ipsum dolor.
  • Sit amet, consectetur.
  • Adipiscing elit.
  • Eos natus suscipit.

.class::first-letter { color: orangered; font-weight: bold; }

.class::first-line {color: royalblue;}

.class::marker {color: lime;}

.class::selection {background-color: magenta;}

.class::before { content: ''; width: 20px; height: 10px; background-color: darkblue; position: absolute; left: 2px; top: 2px; }

Animations

Syntax:

animation: animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction

Examples(hover):

animation: animation1 2s linear infinite alternate;

@keyframes animation1 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }


TEST

animation: animation2 1.5s 2;

@keyframes animation2 { 0% { font-size: 2rem; } 50% { font-size: 3rem; } 100% { font-size: 2rem; } }

Text Formatting

Properties:

  • text-align
  • word-spacing
  • letter-spacing
  • line-height
  • text-transform
  • text-decoration
  • overflow
  • white-space

Examples:

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet id minus reiciendis fugit, assumenda rerum consectetur.

.class { text-align: justify; word-spacing: 5px; letter-spacing: 2px; line-height: 1.2; text-transform: uppercase; }

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet id minus reiciendis fugit, assumenda rerum consectetur harum dolore modi illum, dolorum sunt reprehenderit quo veniam accusamus dolores aut suscipit facilis?

.class { text-align: left; columns: 2; column-rule: 1px dashed red; font-style: italic; font-variant: small-caps; }

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet id minus reiciendis fugit, assumenda rerum consectetur.

.class { white-space: nowrap; overflow: scroll; text-decoration: overline; }

Tables

Examples:

Head 1Head 2Head 3
Cell 1Cell 2Cell 3
Cell 4Cell 5Cell 6
Cell 7Cell 8Cell 9

.table1 { border: 4px solid tomato; padding: 1rem; border-collapse: collapse; }

.table1 th, .table1 td { border: 2px solid tomato; padding: 5px 10px; }

.table1 tr:nth-child(odd) { background-color: lightcyan; }

Head 1Head 2Head 3
Cell 1Cell 2Cell 3
Cell 4Cell 5Cell 6
Cell 7Cell 8Cell 9

.table2 { padding: 1rem; border-collapse: collapse; text-align: left; border-radius: 5px 5px 0 0; overflow: hidden; box-shadow: 0 0 20px #666; }

.table2 thead tr { background-color: slateblue; font-weight: bold; }

.table2 th, .table2 td { padding: 10px 12px; }

.table2 tbody tr:nth-child(even) { background-color: #333; }

.table2 tbody tr:last-of-type { border-bottom: 2px solid slateblue; }