Cascading Style Sheets (CSS 3) : Page 1 of 5 Free Quick Reference Guide
Cascading Style Sheets (CSS 3) : Page 1 of 5 Free Quick Reference Guide
Cascading Style Sheets (CSS 3) : Page 1 of 5 Free Quick Reference Guide
border-left-style border-style clear left | right | both | none overflow-style auto | marquee-line | mar-
quee-block
border-left-width thin | medium | thick display none | inline | block | inline-
length block | list-item | run-in | overflow-x visible | hidden | scroll |
compact | table | inline- auto | no-display | no-
border-right border-right-width table | table-row-group | content
border-style table-header-group | table-
border-color footer-group | table-row | overflow-y visible | hidden | scroll |
table-column-group | table- auto | no-display | no-
border-right-color border-color column | table-cell | table- content
caption | ruby | ruby-base |
border-right-style border-style rotation angle
ruby-text | ruby-base-group
border-right-width thin | medium | thick | ruby-text-group
rotation-point position (paired value off-
length set)
text-emphasis none | [ [ accent | dot | circle TABLE voice-volume silent | x-soft | soft | me-
| disc] [ before | after ]? ] dium | loud | x-loud | inherit
border-collapse collapse | separate number
text-indent length %
% border-spacing length length
LIST & MARKERS
text-justify auto | inter-word | inter- caption-side top | bottom | left | right
ideograph | inter-cluster | list-style list-style-type
distribute | kashida | tibetan empty-cells show | hide list-style-position
list-style-image
text-outline none table-layout auto | fixed
color list-style-image none
length SPEECH url
image-orientation auto
angle
orphans integer
page auto
identifier
windows integer
UI
• Values in italics are place holders for an actual value (like 1px,
1em, 1%), values in normal text are values that can be used as
the actual value
• CSS Properties in Dark Red are shorthand properties and each
value must be defined. The exception is where the property can
define from one to four of the sides of a box element property
(Top-Right-Bottom-Left) - i.e. border-width
:focus an element while the % percentage Universal Any element * { font: 10px Arial; }
element has focus
cm centimeter Type Any element of h1 { text-decoration:
:visited a visited link that type underline; }
in inch
:hover an element when you mouse Grouping Multiple h1, h2, h3 { font-family:
over it mm millimeter elements of Verdana; }
different types
:link an unvisited link
pc pica (1p = 12 points)
Class Multiple .sampleclass { text-
:disabled an element while the elements of decoration: underline; }
element is disabled pt point (1pt = 1/72 inch)
different types
RELATIVE MEASUREMENT when you don’t
:enabled an element while the want to affect
element is enabled all instances of
ch width of the "0" glyph found in
:checked an element (form element the font for the font size used to that type
control) that is checked render
Id A single #sampleid { text-
:selection an element that is currently em 1em = current font size of element type decoration: underline; }
selected of highlighted by current element when you don’t
the user want to affect
ex x-height of the element's font all instances of
:lang Allows the author to specify that type
gd the grid defined by 'layout-grid'
a language to use in a
specified element Descendant An element that #gallery h1 { text-
px pixel of the viewing device is below (in the decoration: underline; }
:nth-child(n) an element that is the n-th rem the font size of the root element document tree)
sibling another
vh the viewport's height element—no
:nth-last-child(n) an element that is the n-th matter how
sibling counting from the vw the viewport's width many levels
last sibling below
vm viewport's height or width,
:first-child an element that is the first whichever is smaller of the two Child An element that #title > p { font-weight:
sibling is directly below bold; }
ANGLES (in the
:last-child an element that is the last document tree)
sibling deg degrees
another
grad grads element
:only-child an element that is the only
child Adjacent All elements h1 + p { font-style:
rad radians
Sibling that share the italic; }
:nth-of-type(n) an element that is the n-th
turn turns same parent
sibling of its type.
and elements
TIME are in the same
:nth-last-of-type(n) an element that is the n-th
sibling of its type counting immediate
ms milli-seconds
from the last sibling sequence
s seconds
:last-of-type an element that is the first General All elements h1 ~ p { font-style:
sibling of its type FREQUENCY Sibling that share the italic; }
same parent
:first-of-type an element that is the last Hz hertz and elements
sibling of its type are in the same
kHz kilo-hertz sequence (not
:only-of-type an element that is the only necessarily
child of that type COLORS
immediate)
:empty an element that has no color name red, blue, green, dark green
Attribute An element with E[selected] - att whatever
children that matches the value
rgb(x,y,z) red = rgb(255,0,0)
the attribute E[att="val"] - att with a
:root root element within the
rgb(x%,y%,z%) red = rgb(100%,0,0) listed specific value
document
E[rel~="next"] - att with
:not(x) an element not represented rgba(x,y,z, alpha) red = rgba(255,0,0) a value is a whitespace
by the argument ‘x’ separated list
#rrggbb red = #ff0000 (or shorthand = *[lang|="en"] - att value
:target a target element as specified #f00) either being exactly "val"
by a target in a URI or beginning with "val"
hsl(hue, saturation, red = hsl(0, 100%, 50%) immediately followed by
PSEUDO-ELEMENT lightness) "-"
E[att^="val"] - att value
::first-letter Adds special style to the first hsla(hue, saturation, red = hsl(0, 100%, 50%)
that begins with the prefix
letter of a text lightness, alpha)
"val"
::first-line Adds special style to the first flavor An accent color (typically chosen E[att$="val"] - att value
line of a text by the user) to customize the that end with the suffix
user interface of the user agent "val"
::before Inserts some content before itsel E[att*="val"] - att value
an element contains at least one
currentColor computed value of the instance of the substring
::after Inserts some content after an 'currentColor' keyword is the "val"
element computed value of the 'color'
property
Font-Style Letter-Spacing
Changes text: normal, oblique, and italics. Defines an additional amount of space between characters.
H1 { font-style: oblique; } H1 { letter-spacing: 0.1em; }
P { font-style: normal; } P.note { letter-spacing: -0.1em; }
Font-Variant Text-Decoration
Used to display font in normal or small-caps. Allows text to be decorated through one of five properties:
SPAN { font-variant: small-caps; } underline, overline, line-through, blink, none.
A:link, A:visited, A:active { text-decoration: none; }
Font-Weight
Used to specify the weight of the font. Vertical-Align
H1 { font-weight: 800; } or P { font-weight: normal; } Used to alter the vertical positioning of an inline element,
relative to its parent element or to the element's line.
Font-Size IMG.middle { vertical-align: middle; }
Used to modify the size of the displayed font. IMG { vertical-align: 50%; }
H1 { font-size: large; } or P { font-size: 12pt; } .exponent { vertical-align: super; }
LI { font-size: 90%; }
STRONG { font-size: larger; } Text-Transform
Allows for capitalizing the first letter of each word (capitalize),
Font capitalizing all letters of a word (uppercase), using all small
Used to combine all properties of fonts. letters in each word(lowercase), and the inital value(none).
P { font: italic bold 12pt/14pt Times, serif; } H1 { text-transform: uppercase; }
H2 { text-transform: capitalize; }
Background-Color Text-Indent
Sets the background color of an element. Used to specify the amount of indentation prior to the first line
BODY { background-color: white; } of text.
H1 { background-color: #000080; } P { text-indent: 5em; }
Background-Image Line-Height
Sets the background image of an element. Used to control the spacing between baselines of text.
BODY { background-image: url(/images/foo.gif); } P { line-height: 200%; }
P { background-image: url(http://www.htmlhelp.com/bg.png); }
Box Properties
Margin-Top Border-Left-Width
Sets the top margin of an element by specifying a length or a Used to specify the width of an element's left border.
percentage. P { border-left: 20%; }
BODY { margin-top: 5pt; }
Border-Width
Margin-Right Used to set the width of an element's border (either all
Sets the right margin of an element by specifying a length or a borders, or specifying top border, right border, bottom border,
percentage. left border).
P.narrow { margin-right: 50%; } P { border-width: 20%; }
P { border-width: 10px 5px 10px 5px; }
Margin-Bottom
sets the bottom margin of an element by specifying a length or Border-Color
a percentage. Used to set the color of an element's border.
DT { margin-bottom: 3em; } P { border-color: #00000; }
Margin-Left Border-Style
sets the left margin of an element by specifying a length or a Sets style of a border - none, dotted, dashed, solid, double.
percentage. P { border-style: dotted; }
ADDRESS { margin-left: 50%; }
Border-Top
Margin Sets the width, style, and color of an element's top border.
Sets the margins of an element by specifying top, bottom, left P { border-top: 10px, red, double; }
and right margins -- all either specifying length or percentage.
BODY { margin: 5em; } /* all margins 5em */ Border-Right
P { margin: 2em 4em; } /* top & bottom 2em, left & right 4em */ Sets the width, style, and color of an element's right border.
DIV { margin: 1em 2em 3em 4em; } P { border-right: 10px, red, double; }
/* top margin 1em, right 2em, bottom 3em, left 4em */
Border-Bottom
Padding-Top Sets the width, style, and color of an element's bottom border.
Describes the amount of space between the top border and P { border-bottom: 10px, red, double; }
the content of the selector.
P { padding-top: 20%; } Border-Left
Sets the width, style, and color of an element's left border.
Padding-Right P { border-left: 10px, red, double; }
Describes the amount of space between the right border and
the content of the selector. Border
P { padding-right: 20 px; } Sets the width, style, and color of an element's border.
P { border: 10px, red, double; }
Padding-Bottom
Describes the amount of space between the bottom border Width
and the content of the selector. Each block-level or replaced element can be given a width,
P { padding-bottom: 5 em; } specified as a length, a percentage, or as auto.
P { width: 15px; }
Padding-Left H1 { width: 35%; }
Describes the amount of space between the left border and .foo { width: auto; }
the content of the selector.
P { padding-left: 15 pt; } Height
Each block-level or replaced element can be given a height,
Padding specified as a length or as auto.
Shorthand for the padding-top, padding-right, padding-bottom, P { height: 15px; }
H1 { height: 35%; }
and padding-left properties.
.foo { height: auto; }
BLOCKQUOTE { padding: 2em 4em 5em 4em; }
Float
Border-Top-Width
Allows text to wrap around an element (left, right, none).
Used to specify the width of an element's top border.
P { float: left; }
P { border-top: 20%; }
H1 { float: right; }
.foo { float: none; }
Border-Right-Width
Used to specify the width of an element's right border.
Clear
P { border-right: 20%; }
Specifies whether an element allows floating elements to its
sides (left, right, none).
Border-Bottom-Width
P { clear: left; }
Used to specify the width of an element's bottom border. H1 { clear: right; }
P { border-bottom: 20%; } .foo { clear: none; }
<>
♥ iLoveCoding
CSS Cheatsheet
Comprehensive video course on HTML & CSS
https://ilovecoding.org/courses/htmlcss
border
(A) Inline styles
TEXT: BACKGROUND: padding
<element style="property: value;"> color background
content
font background-attachment
(B) In the <style> element font-family background-color
font-size background-image
<head> font-weight background-position
....<style> letter-spacing background-repeat
........ selectors { property: value; } line-height
text-align DISPLAY: BOX: POSITION:
....</style>
text-decoration display border position
</head>
text-indent float border-color top
text-transform clear border-style bottom
(C) In a dedicated file (style.css)
vertical-align overflow border-width left
& refer that file via the <link> element
visibility height right
<head> LIST: margin z-index
https://iLoveCoding.org