Difference between h and div?

I am doing this : https://www.freecodecamp.org/learn/responsive-web-design/basic-css/adjust-the-padding-of-an-element

I want to recreate that myself but I found something that I don’t understand why div and h act differently. I understand their functionality, but I don’t understand why h inside div and h by itself produce different visual.

https://codepen.io/dharyadi/pen/dyYwOYX

The top yellow box uses h inside div while the bottom yellow box uses h without div

maybe because h5 have default margin value.

if you add

h5 { 
margin: 0; 
}  

they size and act the same.

i think so does the p element.

Thanks! I didn’t think that h tags have their own default value.

https://www.w3.org/TR/CSS22/sample.html

h5 { font-size: .83em; margin: 1.5em 0 }

terima kasih kembali