HTML and CSS Reference
In-Depth Information
But there's more…
Here's another common way to abbreviate margins (or padding):
top and b
ottom
are the sa
me.
margin-top: 0px;
margin-right: 20px;
margin-bottom: 0px;
margin-left: 20px;
margin: 0px 20px;
And what about the border properties we mentioned?
You can use a shorthand for those too.
Rewr
ite bo
rder
prop
erties
as one
prop
erty. T
hese
can be
in an
y orde
r you
like.
border-width: thin;
border-style: solid;
border-color: #007e7e;
border: thin solid #007e7e;
The border shorthand is even more flexible than margins or padding
because you can specify them in any order you like.
The
se are
all per
fectly
vali
d bord
er sho
rthand
s.
border: solid thin;
border: solid thin #007e7e;
border: #007e7e solid;
border: #007e7e solid thin;
border: solid;
…and don't forget the shorthand for backgrounds
You can also use shorthand for backgrounds:
Like
border
, value
s can g
o in a
ny ord
er
in thi
s short
hand.
There
are a
lso a
few o
ther v
alues y
ou can
specif
y in t
he
background-color: white;
background-image: url(images/cocktail.gif);
background-repeat: repeat-x;
short
hand,
like ba
ckgrou
nd-pos
ition.
background: white url(images/cocktail.gif) repeat-x;