WordPress.org

Ready to get started?Download WordPress

Forums

Set Custom Background class on [html] rather than [body] (6 posts)

  1. jasondrey13
    Member
    Posted 1 year ago #

    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:

    <html>
      <body class="custom-background">
        <div>content</div>
      </body>
    </html>

    I'm trying to get here:

    <html class="custom-background">
      <body>content</body>
    </html>

    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).

    Thanks!

  2. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    You cannot add a background to html tags -- or you can, but it wont show up on the page.

  3. jasondrey13
    Member
    Posted 1 year ago #

    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?
    Thanks!

  4. Jose Castaneda
    Member
    Posted 1 year ago #

    Why not add it via jQuery?

  5. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

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

  6. jasondrey13
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic