Which of the following property is used as the shorthand property of m...
CSS Margin property is used to define the space around elements. The Top, bottom, left and right margin can be changed independently using separate properties. By using the shorthand margin property we can change all margin properties at once.
View all questions of this test
Which of the following property is used as the shorthand property of m...
The correct answer is option C) margin.
Explanation:
The margin property in CSS is used to control the space around elements. It sets the space outside the border of an element. The margin property can be specified for each side of an element (left, right, top, bottom) or as a shorthand property.
The shorthand property of margin allows you to specify the margin for all four sides of an element in a single declaration. It follows the syntax:
margin: top right bottom left;
Here, you can provide values for the top, right, bottom, and left margins in any order you prefer. You can also provide one value to set all four margins equally, two values to set the top and bottom margins and the left and right margins equally, or three values to set the top margin, the left and right margins equally, and the bottom margin.
Using this shorthand property, you can save time and effort by specifying all four margins in a single line of code.
Example:
Suppose you want to set the margin for a div element. Instead of writing separate margin properties for each side, you can use the shorthand property as follows:
div {
margin: 20px 10px 30px 15px;
}
In this example, the top margin is set to 20 pixels, the right margin is set to 10 pixels, the bottom margin is set to 30 pixels, and the left margin is set to 15 pixels.
By using the margin shorthand property, you can easily control the spacing around elements and make your CSS code more concise and efficient.
Which of the following property is used as the shorthand property of m...
CSS Margin property is used to define the space around elements.