One of the main advantages of using CSS is the large reduction in web page download time. To style text, you used to have to use the <font>
tag over and over again. You probably also laid out your site with
tables, nested tables and spacer gifs. Now all that presentational
information can be placed in one CSS document, with each command listed just once.
But why stop there? By using CSS shorthand properties you can reduce the size of your CSS document even more.
This CSS shorthand property will only work if you're specifying both the font-size and the font-family - omit either and the CSS rule will be completely ignored. Also, if you don't specify the font-weight, font-style, or font-varient then these values will automatically default to a value of normal, so do bear this in mind too.
CSS background and lists
Background
Use:
background: #fff url(image.gif) no-repeat top left
...instead of
background-color: #fff;
background-image: url(image.gif);
background-repeat: no-repeat;
background-position: top left;
Omit any of these commands from the background CSS shorthand property, and the browser will use the default values. If you leave out the background-position
command then any background image will be place in the top-left of the
container and then repeated both horizontally and vertically.
Leave out any of these CSS commands from the shorthand rule, and the browser will use the default values for each, namely disc, outside and none (i.e. no images) respectively.
CSS margin and padding
There are a number of different CSS shorthand commands for margin and padding, depending on how many of the sides of the containing element have the same margin or padding values:
Conclusion
CSS shorthand properties are great! They're a great way to reduce the amount of code contained in a CSS document, allowing for faster download times and easier editing. Now who can argue with that?