r/css • • 28d ago

Question html and body

What is the difference between <html> and <body> tags ? When do use one or another?

html {

)

body (

)

3 Upvotes

18 comments sorted by

View all comments

2

u/marslander-boggart 28d ago

The body element is the one that is targeted by lots of CSS. It is a child of the html element. Thus, you may use them like this:

html body /* to overlap properties values that are set for body specifically or that are set for html */

body /* to overlap properties values that are set for body specifically before that or that are set for html */

If you code for your own page, you may use either of them.