1

Is there a difference between setting background in css with body or html? Both work.

eg:

body{
    background: green;
}

or

html{
    background: green;
}
klee
  • 147
  • 1
  • 2
  • 12

2 Answers2

3

Here is a very interesting article.

https://css-tricks.com/html-vs-body-in-css/

Altaula
  • 774
  • 1
  • 7
  • 22
1

The <html> background is "behind" the <body> background. Try this to see what I mean:

html{
  background-color:blue;
}
body{
  background-color:white;
  max-width:400px;
  margin:0 auto;
}
RobertAKARobin
  • 3,933
  • 3
  • 24
  • 46