CSS selectors allow elements to be selected and styled based on element type, class, ID, attributes and more. Basic CSS properties control things like background, borders, text formatting, lists, positioning and box model properties. Special characters have HTML entity equivalents for use in CSS and HTML.
CSS selectors allow elements to be selected and styled based on element type, class, ID, attributes and more. Basic CSS properties control things like background, borders, text formatting, lists, positioning and box model properties. Special characters have HTML entity equivalents for use in CSS and HTML.
.class .intro Selects all elements with class="intro" #id #firstname Selects the element with id="firstname" element p Selects all <p> elements element, element div, p Selects all <div> elements and all <p> elements element element div p Selects all <p> elements inside <div> elements [attribute] [target] Selects all elements with a target attribute [attribute=value] [target=_blank] Selects all elements with target="_blank" :first‐child p:first‐child Selects every <p> element that is the first child of its parent :focus input:focus Selects the input element which has focus :hover a:hover Selects links on mouse over :last‐child p:last‐child Selects every <p> element that is the last child of its parent :not(selector) :not(p) Selects every element that is not a <p> element :nth‐child(n) p:nth‐child(2) Selects every <p> element that is the second child of its parent
Basic CSS Properties Description
background setting all the background properties in one declaration background‐color Specifies the background color of an element background‐image Specifies one or more background images for an element border Sets all the border properties in one declaration border‐bottom Sets all the bottom border properties in one declaration border‐bottom‐left‐radius Defines the shape of the border of the bottom‐left corner border‐bottom‐width Sets the width of the bottom border border‐bottom‐color Sets the color of the bottom border border‐bottom‐style Sets the style of the bottom border text‐align Specifies the horizontal alignment of text text‐decoration Specifies the decoration added to text text‐shadow Adds shadow to text font‐family Specifies the font family for text font‐size Specifies the font size of text font‐style Specifies the font style for text font‐weight Specifies the weight of a font border‐collapse Specifies whether or not table borders should be collapsed list‐style Sets all the properties for a list in one declaration list‐style‐image Specifies an image as the list‐item marker list‐style‐type Specifies the type of list‐item marker
Basic Box Properties Description
bottom Specifies the bottom position of a positioned element display Specifies how a certain HTML element should be displayed height Sets the height of an element width Sets the width of an element left Specifies the left position of a positioned element margin Sets all the margin properties in one declaration margin‐bottom Sets the bottom margin of an element padding Sets all the padding properties in one declaration padding‐top Sets the top padding of an element