Tom's CSS Quick Reference

This is a simple reference guide to the Cascading Style Sheet attributes.

Taken largely from XML: Extensible Markup Language, Elliotte Rusty Harold, IDG Books Worldwide.

Back to my homepage.

Style Tags

<LINK rel="stylesheet" type="text/css" name="name" href="filename">

Links in external style sheet (in <head>)

<STYLE>

Define styles in <head>. Surround with <-- ... -->.

<SPAN>

Used for inline formatting.

<DIV>

Places line breaks (no vertical space) around section.

Attributes

class=""

Specifies style class. Defined with .style

id=""

Unique element id. Defined with #id

May also be used as a target <a href="#id">

style=""

Manually specify or override style for given element.

Lengths

UnitMeaning
emWidth of "m"
exWidth of "x"
pxPixels
ptPoints
inInches
cmCentimeters
mmMillimeters
pcPicas

Font Properties

PropertyValuesComments
font-familyname, serif, sans-serif, monospace, fantasy, cursiveCan specify preferences seperated by commas
font-stylenormal, italic, oblique 
font-variantnormal, small-caps 
font-weightnormal, bold, 100, 200, 300, 400, 500, 600, 700, 800, 900, lighter, bolder 
font-sizexx-small, x-small, small, medium, large, x-large, xx-large, larger, smaller, length, percentage 

Colour and Background Properties

PropertyValuesComments
colorcolour name,#rrggbb 
background-colortransparent, colour name, #rrggbb 
background-imagenone, URL 
background-repeatrepeat, repeat-x, repeat-y, no-repeat 
background-attachmentscroll, fixed 
background-positiontop, center, bottom, length, percentage 

Text Properties

PropertyValuesComments
text-alignleft, right, center, justify 
text-indentlength, percentage 
word-spacingnormal, length 
letter-spacingnormal, length 
text-decorationnone, underline, line-through, overline, blink 
vertical-alignbaseline, sub, super, top, text-top, middle, bottom, text-bottom, percentage 
text-transformcapitalize, uppercase, lowercase, none 

Box Properties

PropertyValuesComments
margin-toplength, percentage, autoSpace outside borders
margin-rightlength, percentage, auto
margin-bottomlength, percentage, auto
margin-leftlength, percentage, auto
marginlength, percentage, autoSpecify all 4 margin spaces
padding-toplength, percentageSpacing inside borders
padding-rightlength, percentage
padding-bottomlength, percentage
padding-leftlength, percentage
paddinglength, percentageSpecify all 4 internal spaces
border-width-toplength, thin, medium, thickWidth of border
border-width-rightlength, thin, medium, thick
border-width-bottomlength, thin, medium, thick
border-width-leftlength, thin, medium, thick
border-widthlength, thin, medium, thickSpecify all 4 border widths
border-colorcolour, #rrggbb 
border-stylenone, dotted, dashed, solid, double, groove, ridge, inset, outset 
widthlength, percentage, auto 
heightlength, percentage, auto 
floatleft, right, none 
clearleft, right, none, both 

Classification Properties

PropertyValuesComments
displayblock, inline, list-item, noneLine breaks before and after element?
white-spacenormal, pre, nowrawHow is whitespace treated?
list-style-typedisc, circle, square, decimal, lower-roman, upper-roman, lower-alpha, upper-alpha, noneList bullet style
list-style-imageURLImage for list bullet
list-style-positioninside, outsidePosition of bullet relative to list items and wrapping