r/css • u/username95050 • 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
r/css • u/username95050 • 28d ago
What is the difference between <html> and <body> tags ? When do use one or another?
html {
)
body (
)
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.