CSS Shorthand for Margins

By [)ia6l0 iii

Margins are specified using the margin-top, margin-bottom, margin-left and margin-bottom properties. CSS allows you to specify these properties through a shorthand notation too.

Instead of using multiple margin properties or attributes, you can use a single shorthand notation.

Look below for a sample.

Instead of ,
margin-top: 5px;
margin-right: 10px;
margin-bottom: 15px;
margin-left: 20px;

Use,
margin: 5px 10px 15px 20px

The order of appearance is Top, Right, Left, and Bottom.

Related FAQs

In CSS , we specify the color using the hexadecimal notation: # followed by the six digits.
CSS Shorthand for Margins  (694 Views)