CSS Common Properties
Introduction
These are some of the more commonly used properties in CSS
CSS Properties
color: sets the color of the text for an element.
color: #333;
color: purple; |
background-color: sets a solid color for the background of an element.
background-color: #fff;
background-color: lime; |
background-image: defines a pointer to an image file which is to
be placed in the background of an element.
| background-image: url(wavy.jpg); |
background-repeat: defines the directions in which a background image will
be repeated.
background-repeat: repeat; (will repeat in x and y directions)
background-repeat: repeat-y;
background-repeat: repeat-x;
background-repeat: no-repeat; |
font-family: declares a comma-separated list of font families for the
text of the element.
| font-family: Helvetica, Arial, Verdana, sans-serif; |
font-size: affects the size of an element’s text. *Its generally better to use relative sizing instead of absolute sizing, so
the user has can adjust their font size to suit their preferences. These are
just a few examples of how sizes can be defined. If you must define an absolute
font-size for some reason, stick with pixels.
|
font-size: 1.2em; (relative)
font-size: 120%; (relative)
font-size: 12px; (absolute)
font-size: 12pt; (absolute, used for print) |
font-style: declares the face of an element’s text.
font-style: italic;
font-style: oblique;
font-style: normal;
|
font-weight: alters the visual weight of text in an element.
font-weight: bold; (equal to 700)
font-weight: 900; (would be really bold)
font-weight: normal;
(equal to 400) |
line-height: modifies the space between lines of text
line-height: 1.1;
(This means 1.1 times the font size. This method is strongly encouraged)
line-height: 130%; |
|