You are on page 1of 6

CSS Reference

CSS Selectors
In CSS, selectors are patterns used to select the element(s) you want to style. The "CSS" column indicates in which CSS version the property is defined (CSS1 or CSS2).

Selector .class #id * element element,element element element element>element element+element [attribute] [attribute=value] [attribute~=value]

Example .intro #firstname * p div,p div p div>p div+p [target] [target=_blank] [title=flower]

Example Selects: All elements with class="intro" The element with id="firstname" All elements All <p> elements All <div> elements and all <p> elements All <p> elements inside <div> elements All <p> elements where the parent is a <div> element

CSS 1 1 2 1 1 1 2

All <p> elements placed immediately after a <div> 2 element All elements with a target attribute All elements with a target attribute equal to "_blank" All elements with a title attribute that contains space separated words, one of which is "flower" All elements where the lang attribute's value is "en", even if the value contains a hyphen (-), like "en-us" All links (<a> elements with href) All visited links Active links Links on mouse over The input element that has focus The first letter of all <p> elements The first line of all <p> elements 2 2 2

[attribute|=language] [lang|=en] :link :visited :active :hover :focus :first-letter :first-line :first-child :before a:link a:visited a:active a:hover input:focus p:first-letter p:first-line p:first-child p:before

2 1 1 1 1 2 1 1

All <p> elements that is the first child of its parent 2 Content will be placed before each <p> element 2

:after :lang(language)

p:after p:lang(it)

Content will be placed after each <p> element

All <p> elements with the lang attribute containing 2 "it"

CSS Properties
CSS Property Groups

Background Border and outline Dimension Font

Generated content List Margin Padding

Positioning Print Table Text

Background Properties
Property background background-attachment background-color background-image background-position background-repeat Description Sets all the background properties in one declaration Sets whether a background image is fixed or scrolls with the rest of the page Sets the background color of an element Sets the background image for an element Sets the starting position of a background image Sets how a background image will be repeated CSS 1 1 1 1 1 1

Border and Outline Properties


Property border border-bottom border-bottom-color border-bottom-style border-bottom-width border-color border-left border-left-color border-left-style border-left-width border-right border-right-color Description Sets all the border properties in one declaration Sets all the bottom border properties in one declaration Sets the color of the bottom border Sets the style of the bottom border Sets the width of the bottom border Sets the color of the four borders Sets all the left border properties in one declaration Sets the color of the left border Sets the style of the left border Sets the width of the left border Sets all the right border properties in one declaration Sets the color of the right border CSS 1 1 1 1 1 1 1 1 1 1 1 1

border-right-style border-right-width border-style border-top border-top-color border-top-style border-top-width border-width outline outline-color outline-style outline-width

Sets the style of the right border Sets the width of the right border Sets the style of the four borders Sets all the top border properties in one declaration Sets the color of the top border Sets the style of the top border Sets the width of the top border Sets the width of the four borders Sets all the outline properties in one declaration Sets the color of an outline Sets the style of an outline Sets the width of an outline

1 1 1 1 1 1 1 1 2 2 2 2

Dimension Properties
Property height max-height max-width min-height min-width width Description Sets the height of an element Sets the maximum height of an element Sets the maximum width of an element Sets the minimum height of an element Sets the minimum width of an element Sets the width of an element CSS 1 2 2 2 2 1

Font Properties
Property font font-family font-size font-style font-variant font-weight Description Sets all the font properties in one declaration Specifies the font family for text Specifies the font size of text Specifies the font style for text Specifies whether or not a text should be displayed in a small-caps font Specifies the weight of a font CSS 1 1 1 1 1 1

Generated Content Properties


Property content counter-increment counter-reset quotes Description Used with the :before and :after pseudo-elements, to insert generated content Increments one or more counters Creates or resets one or more counters Sets the type of quotation marks for embedded quotations CSS 2 2 2 2

List Properties
Property list-style list-style-image list-style-position list-style-type Description Sets all the properties for a list in one declaration Specifies an image as the list-item marker Specifies if the list-item markers should appear inside or outside the content flow Specifies the type of list-item marker CSS 1 1 1 1

Margin Properties
Property margin margin-bottom margin-left margin-right margin-top Description Sets all the margin properties in one declaration Sets the bottom margin of an element Sets the left margin of an element Sets the right margin of an element Sets the top margin of an element CSS 1 1 1 1 1

Padding Properties
Property padding padding-bottom padding-left padding-right padding-top Description Sets all the padding properties in one declaration Sets the bottom padding of an element Sets the left padding of an element Sets the right padding of an element Sets the top padding of an element CSS 1 1 1 1 1

Positioning Properties
Property bottom clear clip cursor display float left overflow position right top visibility z-index Description Sets the bottom margin edge for a positioned box Specifies which sides of an element where other floating elements are not allowed Clips an absolutely positioned element Specifies the type of cursor to be displayed Specifies the type of box an element should generate Specifies whether or not a box should float Sets the left margin edge for a positioned box Specifies the type of positioning for an element Sets the right margin edge for a positioned box Sets the top margin edge for a positioned box Specifies whether or not an element is visible Sets the stack order of an element CSS 2 1 2 2 1 1 2 2 2 2 2 2

Specifies what happens if content overflows an element's box 2

Print Properties
Property orphans Description Sets the minimum number of lines that must be left at the bottom of a page when a page break occurs inside an element Sets the page-breaking behavior after an element Sets the page-breaking behavior before an element Sets the page-breaking behavior inside an element Sets the minimum number of lines that must be left at the top of a page when a page break occurs inside an element CSS 2

page-break-after page-break-before page-break-inside widows

2 2 2 2

Table Properties
Property border-collapse border-spacing caption-side empty-cells table-layout Description Specifies whether or not table borders should be collapsed Specifies the distance between the borders of adjacent cells Specifies the placement of a table caption Specifies whether or not to display borders and background on empty cells in a table Sets the layout algorithm to be used for a table CSS 2 2 2 2 2

Text Properties
Property color direction letter-spacing line-height text-align text-decoration text-indent text-shadow text-transform vertical-align white-space word-spacing Description Sets the color of text Specifies the text direction/writing direction Increases or decreases the space between characters in a text Sets the line height Specifies the horizontal alignment of text Specifies the decoration added to text Specifies the indentation of the first line in a text-block Specifies the shadow effect added to text Controls the capitalization of text Sets the vertical alignment of an element Specifies how white-space inside an element is handled Increases or decreases the space between words in a text CSS 1 2 1 1 1 1 1 2 1 1 1 1

You might also like