zlog 2.

online web periodical.

path: home / archives / 2003 / 09 / 01 / cssshortcuts

CSS Shortcuts
> written 01/09/03. no comments.

Everyone likes shortcuts. It's a fact of life, the shortest route is (nearly) always taken as it requires the least effort and saves you time. This is why I am constantly amazed when I come across people using CSS longhand when it's not needed. For example people often carefully fill out all 6 of the #hex digits for colours when only 3 are needed (web safe only) e.g. #336699 instead of #369 -- the multiple digits are just dropped for the shorthand. Here are another few ways you can cut down on your CSS file size and save a bit of time:

  1. Don't use verbose CSS attributes e.g. specifying all the borders (or margins or padding for that matter) individually or not combining font-size, font-family and line-height into the font attribute.
  2. When specifying something as 0 (e.g. nothing), there is no need to specify a measurement as 0 pixels is the same as 0 inches which in turn is the same as 0 miles. Nothing is nothing no matter what you measure it in.
  3. Write comments as you are making the CSS file to remind you what everything is, but make sure before uploading you strip all but the essential comments. This can often save you a lot of bytes of your CSS file.

comments

add a comment

all html tags will be stripped.