This link has been bookmarked by 23 people . It was first bookmarked on 28 Aug 2012, by Neeraj Aggarwal.
-
26 Oct 14
-
Quite a few shorthand properties are available – for details I suggest the W3C CSS specifications of the background, border, border-color, border-style, border sides (border-top, border-right, border-bottom, border-left), border-width, font, list-style, margin, outline, and padding properties.
-
Colours
-
when a colour consists of three pairs of hexadecimal digits, you can omit one digit from each pair:
#000000becomes#000,#336699becomes#369. -
Box dimensions
-
property:value1;property:value1 value2;property:value1 value2 value3;property:value1 value2 value3 value4;
-
- One value: all sides
- Two values: top and bottom, right and left
- Three values: top, right and left, bottom
- Four values: top, right, bottom, left
-
Margin and padding
-
margin-top:1em;margin-right:0;margin-bottom:2em;margin-left:0.5em;margin:1em 0 2em 0.5em;
But this is much more efficient:
-
Borders
-
border-width:1px;border-style:solid;border-color:#000;border:1px solid #000;
A more compact way would be to use the
bordershorthand: -
border-width:1px 2px 3px 4px;border-top-width:1px;border-right-width:2px;border-bottom-width:3px;border-left-width:4px;
is shorthand for
-
Backgrounds
-
background-color:#f00;background-image:url(background.gif);background-repeat:no-repeat;background-attachment:fixed;background-position:0 0;background:#f00 url(background.gif) no-repeat fixed 0 0;
can be condensed to
-
color:transparentimage:nonerepeat:repeatattachment:scrollposition:0% 0%
The initial values for the individual background properties are as follows:
-
Fonts
-
font-style:italic;font-variant:small-caps;font-weight:bold;font-size:1em;line-height:140%;font-family:"Lucida Grande",sans-serif;font:italic small-caps bold 1em/140% "Lucida Grande",sans-serif;
Can be combined into
-
font-style:normalfont-variant:normalfont-weight:normalfont-size:mediumline-height:normalfont-family: depends on the user agent
When using the
fontshorthand you can omit any values exceptfont-sizeandfont-family– you always need to give values for those, and in that order. The initial values for the individualfontproperties are these: -
Lists
-
list-style:none;list-style-type:none;
instead of
-
list-style:square inside url(image.gif);list-style-type:square;list-style-position:inside;list-style-image:url(image.gif);
is shorthand for
-
Outlines
-
outline-color:#f00;outline-style:solid;outline-width:2px;outline:#f00 solid 2px;
or like this:
-
-
15 May 14
-
18 Oct 13
-
09 May 13
-
04 Nov 12
Kaspars ZemītisGOOD
-
28 Aug 12
-
18 Nov 11
-
10 May 10
-
10 Feb 09
-
22 Aug 06
-
24 Apr 06
-
31 Jan 06
-
22 Feb 05
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.