What is the difference between applying css rules to html compared to body?

前端 未结 5 911
梦如初夏
梦如初夏 2020-12-01 16:06

I don\'t see the difference between:

html {
    background: #f1f1f1;
}

and

body {
    background: #f1f1f1;
}
5条回答
  •  情话喂你
    2020-12-01 16:21

    There shouldn't normally be any difference at all, because those elements are both supposed to be taking up the full screen. It's just like having a div inside some other div. But I think it's more correct to style the body tag, because html isn't really part of the layout.

提交回复
热议问题