Welcome to the Treehouse Community
Looking to learn something new?
margin-right:0; and margin:initial
I noticed that in media queries we sometimes set elements to Zero or intial. What is the difference between margin:initial and marging-right:0
Chris Shaw26,662 Points
Hi orange sky,
It depends on the element, some elements have default margins therefore setting a zero margin might be different from initial which inherits the default offset of the browser, generally you wouldn't use
initial on margins as there is not typical scenario where you need to reset an elements margins.
Jacky Giang10,596 Points
Each CSS property has an 'initial' value unaffected by the browser default. This value is defined in CSS specifications. So, setting margin to 'initial' will revert all four margins (top, right, bottom, left) back to its CSS specification. Click here for some examples on how 'initial' is used.
Now, that's true if its value is not inherited from a parent element... It can get confusing in this inherited scenario, but click here if you want to read more!
'margin-right: 0' only sets the element's right margin to 0.
Would an element with a margin-right:0 look different from margin:right:initial?
In fact, do you know a direct link to view the intial values of most major elements?
Thanks Chris! That was very specific!