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.


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.


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

terima kasih kembali