Computer Applications

How can we set the margins for an element?

CSS

7 Likes

Answer

We can specify the margin for all the sides of an element in one single declaration by using the Margin shorthand property.

Syntax — Margin : top-value right-value bottom-value left-value where value can be length or percentage or 'auto'.

For example, to define the margins for <P> element, we will use the following rule:

P {margin: 20px 40px 60px 80px}

Answered By

4 Likes


Related Questions