Selected CSS Attributes

Part of the HTML, XHTML, and CSS All-in-One For Dummies Cheat Sheet

CSS (Cascading Style Sheets) helps you create dynamic Web pages and gives you more control over how a Web page looks and acts. Knowing CSS attributes and how to use them is key to making your Web page designing life a little easier. The table here shows commonly used attributes and their functions:

Attribute Function
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 image will repeat: repeat, repeat-x, repeat-y, and no-repeat
font-family Font name: sans-serif, serif, monospace, cursive, and fantasy
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 both

Comments (0)

Leave a Reply


Post Comment

SERIES
HTML, XHTML, and CSS All-in-One For Dummies Cheat Sheet

Grab a free widget and we'll bring interesting & helpful tips to your favorite personal page each day

Sign Up for RSS Feeds

Computers & Software

Inside Dummies.com