2

In a project that I was assigned to fix some stuff in, I just stumbled upon this:

<html lang="de" style="background-image: url(assets/img/detail_bg.jpg);">

To me it feels plain wrong to apply a background-image on the root element; I'd rather put this on the body instead, or even further down the DOM in a wrapping div.

Yet I wasn't able to find information on this.

Can anyone shed some light as of what is allowed/recommended/discouraged to do on the root element? Links very welcome.

connexo
  • 53,704
  • 14
  • 91
  • 128
  • 1
    Its perfectly fine to use on the `` tag. There are not any disadvantages. – Red Sep 11 '17 at 11:22
  • 1
    You can find proper explanation of when to use background-image to or here : https://stackoverflow.com/questions/10947541/applying-a-background-to-html-and-or-body – Shruti Agarwal Sep 11 '17 at 11:23
  • 2
    Applying it to `` will work due to the generous nature of browsers, but as per the [official spec](https://www.w3.org/TR/css3-background/#special-backgrounds): "It is recommended that authors of HTML documents specify the canvas background for the BODY element rather than the HTML element." – Rhumborl Sep 11 '17 at 11:26

0 Answers0