- body has margin: 0
- p tags has margin-top: 100px;
p tags affects body's margin-top why?
I expected margin-top:100px only affects p tags.
///////////////////////////////////////////////////////
I wonder why should I use padding-top instead of margin-top?
Margins create extra space around an element. In contrast, padding creates extra space within an element.
In this case p tags are located in body so margin and padding should be looks same
https://stackblitz.com/edit/react-lktg4q?file=style.css
html, body {
margin: 0;
height: 100%;
}
h1, p {
font-family: Lato;
margin: 0;
margin-top:100px;
}
#root {
background: blue;
height: 100vh;
}
<div>
<Hello name={this.state.name} />
<p>
Start editing to see some magic happen :)
</p>
</div>