Wednesday, July 1, 2015

How are shorthand properties are used in css? Give examples.



One of the primary advantages of css is that it greatly reduces page load times. Writing multiple properties and their values in a single line of css code is known as css shorthand technique. One thing to be kept in mind is that while using the css shorthand technique is that the order of specifying the values of an attribute must be maintained. In case the user wants to keep a value as default it is not needed to be mentioned.
For ex.
margin-top: 5em;
margin-bottom: 3em;
margin-right: 1em;
margin-left: 1em
Becomes:
margin: 5em 1em 3em (top, right and left, bottom);

border-width:5px;
border-style:solid;
border-color:#fff;
Becomes:
border:5px solid #fff;

No comments:

Post a Comment