The best CSS margin property Tutorial In 2024, In this tutorial you can learn Examples,Attribute definitions and instructions,Browser Support,Property Value,related articles,
A p element set all four margins:
margin shorthand property sets all margin properties in one declaration. This property can have the value 1-4.
Example:
Note: negative values are allowed.
Defaults: | 0 |
---|---|
inherit: | no |
version: | CSS1 |
JavaScript syntax: | object .style.margin = "10px 5px" |
Figures in the table represent the first browser to support the version number of the property.
属性 | |||||
---|---|---|---|---|---|
margin | 1.0 | 6.0 | 1.0 | 1.0 | 3.5 |
value | description |
---|---|
auto | Browser calculated margin. |
length | In particular the provisions margin Unit of value, such as pixels, centimeters, and the like. The default value is 0px. |
% | Based on a predetermined percentage of the parent element width margins. |
inherit | The provisions margin should inherit from the parent element. |
CSS tutorial: CSS Margin