The Power of CSS Shorthand
So many web developers specially those who are new to the whole HTML CSS thing, will normally write out every single line of code exactly as they were taught.
There is nothing wrong with this type of coding, the only problem is that it takes up a lot of extra time, and from my experience, clients are not interested in what will take the longest, clients want things to happen snappy.
If you've been in coding for quite some time or just starting out, these examples that I'll be giving you will definitely help to code faster and smarter. It can make such a big difference, for example, a css file that contains 1000 lines of code, can become a 500 line css file simply by using shorthand css procedures.
replace the margin for when using padding
There is nothing wrong with this type of coding, the only problem is that it takes up a lot of extra time, and from my experience, clients are not interested in what will take the longest, clients want things to happen snappy.
If you've been in coding for quite some time or just starting out, these examples that I'll be giving you will definitely help to code faster and smarter. It can make such a big difference, for example, a css file that contains 1000 lines of code, can become a 500 line css file simply by using shorthand css procedures.
1. Background Attribute - CSS Tag
Normal CSS
background-image: url(images);
background-position: 10px 50px;
background-repeat: no-repeat;
background-color: #fff;
Shorthand CSS
background: #fff url(image) 10px 50px no-repeat;
2. Margin & Padding Attribute - CSS Tag
replace the margin for when using padding
Normal CSS
margin-left: 10px;
margin-right: 10px;
margin-top: 10px;
margin-bottom: 10px;
Shorthand CSS
margin: top right bottom left; "For individual margins"
Normal CSS
Normal CSS
3. Border Attribute - CSS Tag
border-width: 2px;
border-style: solid;
boder-color: #000;
border-style: solid;
boder-color: #000;
Shorthand CSS
border: solid 2px #000;
4. Font Attribute - CSS Tag
Normal CSS
font-family: Verdana, Arial;
font-size: 15px;
font-weight: bold;
font-style: italic;
line-height: 1.5px;
font-size: 15px;
font-weight: bold;
font-style: italic;
line-height: 1.5px;
Shorthand CSS
font: italic bold 15px/1.5 Verdana, Arial;
Aqua: #00ffff to #0ff
Black: #000000 to #000
Blue: #0000ff to #00f
Dark Grey: #666666 to #666
Fuchsia:#ff00ff to #f0f
Light Grey: #cccccc to #ccc
Lime: #00ff00 to#0f0
Orange: #ff6600 to #f60
Red: #ff0000 to #f00
White: #ffffff to #fff
Yellow: #ffff00 to #ff0
5. Color Attribute - CSS Tag
Aqua: #00ffff to #0ff
Black: #000000 to #000
Blue: #0000ff to #00f
Dark Grey: #666666 to #666
Fuchsia:#ff00ff to #f0f
Light Grey: #cccccc to #ccc
Lime: #00ff00 to#0f0
Orange: #ff6600 to #f60
Red: #ff0000 to #f00
White: #ffffff to #fff
Yellow: #ffff00 to #ff0