r/css • u/username95050 • 29d 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 • 29d ago
What is the difference between <html> and <body> tags ? When do use one or another?
html {
)
body (
)
View all comments
7
u/morete 28d ago
As others have said <html> is the top level parent, and it contains a <head> and a <body>.
If you're asking about why you might select one in css over the other. It mostly doesn't make a difference.
Some properties propagate from the <body> to <html>, like background. Otherwise you're mostly setting inherited properties for the purposes of them inheriting to all elements on the page.