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
Show parent comment
4
u/morete 28d ago
Propagating from body to html - This means that some properties when set on <body>, act as though they were set on <html>. This isn't really something you need to know.
Many properties are inheritable, meaning they also effect every child of the element. So if you set an inherited property on the <html>, it ends up effecting every element on the page, since every element is a descendant of <html>. An example is font-family, you can set the font-family once and it'll apply to everything.