Support » Themes and Templates » Set Custom Background class on [html] rather than [body]

  • Hi,

    I’m using a set up like Constellation Theme Demo where the html element is the only element that is 100% of the viewport, and the rest of the page is contained in a fixed-width, centered body element with margins.

    I’m not really able to move things around to re-wrap everything in a new div element, and I’d like to keep the code clean and simple (I’ve managed to build everything with semantic markup).

    How can I make the new custom background features apply to the <html> element on the page, rather than the <body> element?

    That is, from the standard functionality:

      <body class="custom-background">

    I’m trying to get here:

    <html class="custom-background">

    I can’t imagine it should take too much tweaking, I just don’t know where to start. I also don’t need to worry about the theme being backwards compatible (building for a specific non-profit which is already updated).


Viewing 5 replies - 1 through 5 (of 5 total)
  • You cannot add a background to html tags — or you can, but it wont show up on the page.

    I actually already have default backgrounds working nicely in all browsers- adding a background to the HTML element in the CSS. It’s not a display issue- it’s just that WordPress adds the “custom-background” CSS class to the body tag by default, and I need the tag to be inserted in the HTML element.

    Any ideas?

    Moderator Jose Castaneda



    Why not add it via jQuery?

    If that’s the case, why can’t you add it directly in the CSS syle.css file?

    I’m trying to get the “Custom Background” feature built into WordPress to work on the html tag- I can’t hard code the image into the theme, because the theme is for a multisite installation, and each will be different.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Set Custom Background class on [html] rather than [body]’ is closed to new replies.