0

I noticed the following in some CSS code:

html,
body {
font: 20px;    
}

At first glance, it seems kind of redundant to select both html and body tags. Isn't selecting the body sufficient? The body is, after all, what appears on a viewer's screen.

Is there an advantage to doing this?

  • Was there other code? If there is code like `height: 100%` this would need to apply to html and body for full cross-browser support. – HackerMan Aug 04 '20 at 03:27
  • 1
    With some old browsers, `html` has its own styles, that you might want to clear it. Also, it controls the root font size (`rem`). So if you want to set `1rem` to a specific `px` value, you need to set it in `html` (or `:root`) selector. – Hao Wu Aug 04 '20 at 03:27
  • https://css-tricks.com/html-vs-body-in-css/ – TylerH Aug 04 '20 at 03:38

0 Answers0