css 2 visual cheat sheet

3
HOW TO / 2. SELECTORS LEGEND E Element (pc) Pseudo Class (s) Selector U Universal T Type D Descendant * Matches any element. U (s) E Matches any E element (div, span, p,…). T (s) E F Matches any F element that is a descendant of an E element. D (s) E > F Matches any F element that is a child of an element E. C (s) E:first-child Matches element E when E is the first child of its parent. :first-child (pc) E:link / E:visited Matches element E if E is the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited). link (pc) E:active / E:hover / E:focus Matches E during certain user actions. dynamic (pc) E:lang(c) Matches element of type E if it is in (human) language c (the document language specifies how language is determined). :lang() (pc) E + F Matches any F element immediately preceded by a sibling element E. Ad (s) E[foo] Matches any E element with the "foo" attribute set (whatever the value). Att (s) E[foo="warning"] Matches any E element whose "foo" attribute value is exactly equal to "warning". Att (s) E[foo~="warning"] Matches any E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning". Att (s) E[lang|="en"] Matches any E element whose "lang" attribute has a hyphen-separated list of values beginning (from the left) with "en". Att (s) DIV.warning Language specific. (In HTML, the same as DIV [class~="warning"]). Class (s) E#myid Matches any E element with ID equal to "myid". ID (s) C HOW TO / 1. SYNTAX Include an external style sheet Use the following syntax to include an external style sheet on your pages: <head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head> Basic syntax The CSS syntax is made up of three parts: a selector, a property and a value: selector {property:value} T How to use: body {color:black} Grouping You can group selectors separating each selector with a comma. T How to use: p, h1,h2,h3,h4,h5,h6, form {margin:0;} Add styles to elements with particular attributes You can also apply styles to HTML elements with particular attributes. The style rule below will match all input elements that have a type attribute with a value of "text". T How to use: input[type="text"] {background-color:blue} Comments A comment will be ignored by browsers. T How to use: /* This is a comment */ PSEUDO CLASSES :active Adds a style to an element that is activated. T How to use: a:active must come after a:hover in the CSS definition in order to be effective. :after Adds content after an element. :before Adds content before an element. :first-child Adds a style to an element that is the first child of another element. :first-letter Adds a style to the first character of a text. :first-line Adds a style to the first line of a text. :focus Adds a style to an element that has keyboard input focus. :hover Adds a style to an element when you mouse over it. T How to use: a:hover must come after a:link and a:visited in the CSS definition in order to be effective. :lang Adds a style to an element with a specific lang attribute. :link Adds a style to an unvisited link. :visited Adds a style to a visited link. C Child Ad Adjacent Att Attribute Shorthand property T Notes Designed by Antonio Lupetti • http://woorkup.com • http://www.twitter.com/woork CSS 2 VISUAL CHEAT SHEET ESSENTIAL REFERENCE GUIDE TO CASCADING STYLE SHEETS LEVEL 2 BACKGROUND background Sets all the background properties in one declaration. background-attachment Sets whether a background image is fixed or scrolls with the rest of the page. scroll | fixed | inherit background-color Sets the background color of an element. color_name | hex_number | rgb_number | transparent | inherit background-image Sets the background image for an element. url('image_url') | none | inherit background-position Sets the starting position of a background image. top left | top center | top right | center left | center center | center right | bottom left | bottom center | bottom right | x% y% | x-pos y- pos | inherit background-repeat Sets how a background image will be repeated. repeat | repeat-x | repeat-y | no-repeat | inherit FONT font Sets all the font properties in one declaration. font-family Specifies the font family for text. family-name | generic-family font-size Specifies the font size of text. xx-small | x-small | small | medium | large | x-large | xx-large | smaller | larger | length | % | inherit font-style Specifies the font style for text. normal | italic | oblique | inherit font-variant Specifies whether or not a text should be displayed in a small-caps font. normal | small-caps | inherit font-weight Specifies the weight of a font. normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit f SIZE AND COLORS Relative Size em | ex | % Absolute Size cm | in | mm | pc | pt | px Colours RGB Notation Hex notation #0033CC | RGB notation: rgb (0, 12, 12)

Upload: antonio-lupetti

Post on 12-Nov-2014

31.318 views

Category:

Documents


2 download

DESCRIPTION

CSS2 Visual Cheat Sheet is an useful and practical reference to Cascading Style Sheets Level 2 for web designers and developers designed by Antonio Lupetti (http://woorkup.com). This cheat sheet (3 pages) contains an essential reference to CSS2 properties with detailed descriptions and some sample code. The simple visual style used to design this sheet allows you to find at a glance everything you are looking for. Here’s a preview.

TRANSCRIPT

Page 1: CSS 2 Visual Cheat Sheet

★ HOW TO / 2. SELECTORSLEGEND

E Element

(pc) Pseudo Class

(s) Selector

U Universal

T Type

D Descendant

*Matches any element.

U (s)

EMatches any E element (div, span, p,…).

T (s)

E FMatches any F element that is a descendant of an E element.

D (s)

E > FMatches any F element that is a child of an element E.

C (s)

E:first-childMatches element E when E is the first child of its parent.

:first-child (pc)

E:link / E:visitedMatches element E if E is the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited).

link (pc)

E:active / E:hover / E:focusMatches E during certain user actions.

dynamic (pc)

E:lang(c)Matches element of type E if it is in (human) language c (the document language specifies how language is determined).

:lang() (pc)

E + FMatches any F element immediately preceded by a sibling element E.

Ad (s)

E[foo]Matches any E element with the "foo" attribute set (whatever the value).

Att (s)

E[foo="warning"]Matches any E element whose "foo" attribute value is exactly equal to "warning".

Att (s)

E[foo~="warning"]Matches any E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning".

Att (s)

E[lang|="en"]Matches any E element whose "lang" attribute has a hyphen-separated list of values beginning (from the left) with "en".

Att (s)

DIV.warningLanguage specific. (In HTML, the same as DIV[class~="warning"]).

Class (s)

E#myidMatches any E element with ID equal to "myid".

ID (s)

C

★ HOW TO / 1. SYNTAX

Include an external style sheetUse the following syntax to include an external style sheet on your pages:

<head><link rel="stylesheet" type="text/css" href="mystyle.css" /></head>

Basic syntaxThe CSS syntax is made up of three parts: a selector, a property and a value:

selector {property:value}

T How to use:

body {color:black}

GroupingYou can group selectors separating each selector with a comma.

T How to use:

p, h1,h2,h3,h4,h5,h6, form {margin:0;}

Add styles to elements with particular attributesYou can also apply styles to HTML elements with particular attributes. The style rule below will match all input elements that have a type attribute with a value of "text".

T How to use:

input[type="text"] {background-color:blue}

CommentsA comment will be ignored by browsers.

T How to use:

/* This is a comment */

★ PSEUDO CLASSES

:activeAdds a style to an element that is activated.

T How to use:

a:active must come after a:hover in the CSS definition in order to be effective.

:afterAdds content after an element.

:beforeAdds content before an element.

:first-childAdds a style to an element that is the first child of another element.

:first-letterAdds a style to the first character of a text.

:first-lineAdds a style to the first line of a text.

:focusAdds a style to an element that has keyboard input focus.

:hoverAdds a style to an element when you mouse over it.

T How to use:

a:hover must come after a:link and a:visited in the CSS definition in order to be effective.

:langAdds a style to an element with a specific lang attribute.

:linkAdds a style to an unvisited link.

:visitedAdds a style to a visited link.

C Child

Ad Adjacent

Att Attribute

✽Shorthand

property

T Notes

Designed by Antonio Lupetti

• http://woorkup.com • http://www.twitter.com/woork

CSS 2 VISUAL CHEAT SHEET ★ ESSENTIAL REFERENCE GUIDE TO CASCADING STYLE SHEETS LEVEL 2

★ BACKGROUND

✽ backgroundSets all the background properties in one declaration.

background-attachmentSets whether a background image is fixed or scrolls with the rest of the page.

scroll | fixed | inherit

background-colorSets the background color of an element.

color_name | hex_number | rgb_number |

transparent | inherit

background-imageSets the background image for an element.

url('image_url') |none | inherit

background-positionSets the starting position of a background image.

top left | top center | top right | center left | center center | center

right | bottom left | bottom center | bottom right | x% y% | x-pos y-

pos | inherit

background-repeatSets how a background image will be repeated.

repeat | repeat-x | repeat-y | no-repeat |

inherit

★ FONT

✽ fontSets all the font properties in one declaration.

font-familySpecifies the font family for text.

family-name | generic-family

font-sizeSpecifies the font size of text.

xx-small | x-small | small | medium | large |

x-large | xx-large | smaller | larger | length | % |

inherit

font-styleSpecifies the font style for text.

normal | italic | oblique | inherit

font-variantSpecifies whether or not a text should be displayed in a small-caps font.

normal | small-caps | inherit

font-weightSpecifies the weight of a font.

normal | bold | bolder | lighter | 100 | 200 | 300 |

400 | 500 | 600 | 700 | 800 | 900 | inherit

f

★ SIZE AND COLORS

Relative Size em | ex | %

Absolute Size cm | in | mm | pc | pt | px

ColoursRGB Notation Hex notation

#0033CC | RGB notation: rgb (0, 12, 12)

Page 2: CSS 2 Visual Cheat Sheet

★ DIMENSION ★ POSITIONING

heightSets the height of an element.

T The height property does not include padding, borders, or margins.

auto | length | % | inherit

max-heightSets the maximum height of an element.

none | length | % | inherit

max-widthSets the maximum width of an element.

none | length | % | inherit

min-heightSets the minimum height of an element.

length | % | inherit

min-widthSets the minimum width of an element.

length | % | inherit

widthSets the width of an element.

T The width property does not include padding, borders, or margins.

auto | length | % | inherit

★ MARGIN

✽ marginSets all the margin properties in one declaration (order: top, right, bottom, left).

T How to use:

p{margin:10px 5px 15px 20px;}

auto | length | % | inherit

margin-bottomSets the bottom margin of an element.

auto | length | % | inherit

margin-leftSets the left margin of an element.

auto | length | % | inherit

margin-rightSets the right margin of an element.

auto | length | % | inherit

margin-topSets the top margin of an element.

auto | length | % | inherit

★ PADDING

✽ paddingSets all the padding properties in one declaration (order: top, right, bottom, left).

T How to use:

p{padding:10px 5px 15px 20px;}

length | % | inherit

padding-bottomSets the bottom padding of an element.

length | % | inherit

padding-leftSets the left padding of an element.

length | % | inherit

padding-rightSets the right padding of an element.

length | % | inherit

padding-topSets the right padding of an element.

length | % | inherit

★ OUTLINE

✽ outlineSets all the outline properties in one declaration.

T An outline is a line that is drawn around elements (outside the borders) to make the element "stand out".

outline-color | outline-style |

outline-width | inherit

outline-colorSets the color of an outline.

color_name | hex_number |

rgb_number | invert | inherit

outline-styleSets the style of an outline.

none | hidden | dotted | dashed | solid |

double | groove | ridge | inset | outset |

inherit

outline-widthSets the width of an outline.

length | thin | medium | thick

bottomSets the bottom margin edge for a positioned box.

auto | length | % | inherit

clearSpecifies which sides of an element where other floating elements are not allowed.

left | right | both | none | inherit

clipClips an absolutely positioned element.

shape | auto | inherit

cursorSpecifies the type of cursor to be displayed.

url | auto | crosshair | default | e-resize | help |

move | n-resize | ne-resize | nw-resize |

pointer | progress | s-resize | se-resize |

sw-resize | text | w-resize | wait | inherit

displaySpecifies the type of box an element should generate.

none | block | inline | inline-block |

inline-table | list-item | run-in | table |

table-caption | table-cell | table-column |

table-column-group | table-footer-group |

table-header-group | table-row |

table-row-group | inherit

floatSpecifies whether or not a box should float.

left | right | none | inherit

leftSets the left margin edge for a positioned box.

auto | length | % | inherit

overflowSpecifies what happens if content overflows an element's box.

visible | hidden | scroll | auto | inherit

positionSpecifies the type of positioning for an element.

absolute | fixed | relative | static | inherit

rightSets the right margin edge for a positioned box.

auto | length | % | inherit

topSets the top margin edge for a positioned box.

auto | length | % | inherit

visibilitySpecifies whether or not an element is visible.

visible | hidden | collapse | inherit

z-indexSets the stack order of an element.

auto | number | inherit

★ BORDER

✽ borderSets all the border properties in one declaration.

✽ border-colorSets the color of the four borders.

color_name | hex_number | rgb_number | transparent |

inherit

✽ border-styleSets the style of the four borders.

none | hidden | dotted | dashed | solid | double |

groove | ridge | inset | outset

✽ border-widthSets the width of the four borders.

length | thin | medium | thick

✽ border-topSets all the top border properties in one declaration.

border-top-color | border-top-style | border-top-width

border-top-colorSets the color of the top border.

color_name | hex_number | rgb_number |

transparent | inherit

border-top-styleSets the style of the top border.

border-style

border-top-widthSets the width of the top border.

border-width

✽ border-rightSets all the right border properties in one declaration.

border-right-color | border-right-style | border-right-width

border-right-colorSets the color of the right border.

color_name | hex_number | rgb_number |

transparent | inherit

border-right-styleSets the style of the right border.

border-style

border-right-widthSets the width of the right border.

border-width

✽ border-bottomSets all the bottom border properties in one declaration.

border-bottom-color | border-bottom-style | border-bottom-width

border-bottom-colorSets the color of the bottom border.

color_name | hex_number | rgb_number |

transparent | inherit

border-bottom-styleSets the style of the bottom border.

border-style

border-bottom-widthSets the width of the bottom border.

border-width

✽ border-leftSets all the left border properties in one declaration.

border-left-color | border-left-style |

border-left-width

border-left-colorSets the color of the left border.

color_name | hex_number | rgb_number |

transparent | inherit

border-left-styleSets the style of the left border.

border-style

border-left-widthSets the width of the left border.

border-width

CSS 2 VISUAL CHEAT SHEET ★ ESSENTIAL REFERENCE GUIDE TO CASCADING STYLE SHEETS LEVEL 2

Page 3: CSS 2 Visual Cheat Sheet

★ TEXT

colorSets the color of text.

color_name | hex_number | rgb_number | inherit

directionSpecifies the text direction/writing direction.

ltr | rtl | inherit

letter-spacingIncreases or decreases the space between characters in a text.

normal | length | inherit

line-heightSets the line height.

normal | number | length | % | inherit

text-alignSpecifies the horizontal alignment of text.

left | right | center |justify | inherit

text-decorationSpecifies the decoration added to text.

none | underline | overline | line-through |

blink | inherit

text-indentSpecifies the indentation of the first line in a text-block.

length | % | inherit

text-shadowSpecifies the shadow effect added to text.

text-transformControls the capitalization of text.

none | capitalize | uppercase | lowercase |

inherit

vertical-alignSets the vertical alignment of an element.

length | % | baseline | sub | super | top |

text-top middle | bottom | text-bottom | inherit

white-spaceSpecifies how white-space inside an element is handled.

normal | nowrap | pre |pre-line | pre-wrap|

inherit

word-spacingIncreases or decreases the space between words in a text.

normal | length | inherit

★ LIST ★ REFERENCE AND CREDITS

★ TABLE

✽ list-styleSets all the properties for a list in one declaration.

list-style-type | list-style-position |

list-style-image | inherit

list-style-imageSpecifies an image as the list-item marker.

url | outside | inherit

list-style-positionSpecifies where to place the list-item marker.

inside | outside | inherit

list-style-typeSpecifies the type of list-item marker.

none | circle | disc | square | armenian |

decimal | decimal-leading-zero |

georgian | lower-alpha | lower-greek | lower-latin |

lower-roman | upper-alpha | upper-latin |

upper-roman | inherit

border-collapseSpecifies whether or not table borders should be collapsed.

collapse | separate | inherit

border-spacingSpecifies the distance between the borders of adjacent cells.

length length | inherit

caption-sideSpecifies the placement of a table caption.

top | bottom | inherit

empty-cellsSpecifies whether or not to display borders and background on empty cells in a table.

hide | show | inherit

table-layoutSets the layout algorithm to be used for a table.

auto | fixed | inherit

CSS 2 Visual Cheat Sheet

Designed © 2009 by Antonio Lupetti• http://woorkup.com • http://www.twitter.com/woork• http://www.facebook.com/antoniolupetti

Download this Visual Cheat Sheet here:• http://woorkup.com

Source W3School • http://w3school.com/

THE WORKING BRAIN

k

T ★ PRINT

orphans Sets the minimum number of lines that must be left at the bottom of a page when a page break occurs inside an element.

page-break-afterSets the page-breaking behavior after an element.

auto | always | avoid | left | right | inherit

page-break-beforeSets the page-breaking behavior before an element.

auto | always | avoid | left | right | inherit

page-break-insideSets the page-breaking behavior inside an element.

auto | avoid | inherit

widows Sets the minimum number of lines that must be left at the top of a page when a page break occurs inside an element.

★ GENERATED CONTENT

contentUsed with the :before and :after pseudo-elements, to insert generated content.

none | normal | content specifications |

inherit

counter-incrementIncrements one or more counters.

none | id number | inherit

counter-resetCreates or resets one or more counters.

none | id number | inherit

quotesSets the type of quotation marks for embedded quotations.

none | string string string string | inherit

CSS 2 VISUAL CHEAT SHEET ★ ESSENTIAL REFERENCE GUIDE TO CASCADING STYLE SHEETS LEVEL 2