Selected CSS Attributes

Part of HTML5 and CSS3 All-in-One For Dummies Cheat Sheet

This table highlights the most commonly used CSS attributes. Each of these attributes can be applied to any container element in a page. The container can be a single element denoted by the ID attribute, a member of a class, or all the elements in a page of a certain type.

Attribute Discussion
margin Defines space between element border and parent (left, right,
top, bottom variations)
padding Defines space between contents and border (with variants)
border: size color style Defines a border. Styles: none, dotted, dashed, solid, double,
groove, ridge, inset, and outset.
color Foreground color: color name or hex value
background-color Background color: color name or hex value
background-image: url(filename) Sets image indicated by filename as background image
background-repeat Indicates how background will repeat: repeat, repeat-x,
repeat-y, and no-repeat
font-family Font name: sans-serif, serif, monospace, cursive, and
font-size Font size (best specified in ems or percent)
font-style Set italics: none, italic, and oblique
font-weight Set boldness: lighter, normal, bold, and bolder (100-900)
text-align Alignment: left, right, center, and justify. Works on
content, not a block
text-decoration Adds decoration to text: none, underline, overline,
line-through, and blink
display Defines how element is displayed: none, block, and inline
position Describes positioning scheme: absolute and relative
left, top, right, bottom Indicates position of element (must set position absolute or
relative first)
float Removes element from normal layout and floats it in a
direction: left and right
height, width Specifies the height and width of an element. Important for
floated elements.
clear Force this floated element to position: left, right, and