It's much more easy to me to explain it by simple example:
<img src='...'>
img {
margin: 30;
width: 100;
height: 200;
}
If there's no px or percentage declared for margin, width and height, what would be the measure unit for it then?
Its much more easy to explain this with a metaphor:
You wanna buy a plate for your table in a hardware store. The service guy ask you with length and width the plate should have. You say: "100 x 200"
. His Face 🤔
The Problem is those units could be anything: mm, cm, px, apples. To go on with the metaphor, the browser now is the service guy and has absolute now clue what you mean with width: 100; and no value. Therefore he just take 0 = no margin because this is the default value for margin
. Basically all styles that define dimensions or measurements need a value, else those are null
.
According the W3C:
margin
default value: 0padding
default value: 0width
default value: autoheight
default value: autoHope this helps for understanding. A list with all default values can be found here: https://www.w3schools.com/cssref/css_default_values.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With