WordPress.org

Ready to get started?Download WordPress

Forums

CSS and Post Backbround Color (6 posts)

  1. cspicer
    Member
    Posted 3 years ago #

    Hello,

    I am trying to override my theme's CSS in a post by using an embedded set of rules in the HTML section of a post. I want to color the background of a post and I have added the CSS rule below with no luck. I have no problem changing other aspects of a post such as fonts and formatting tables including the background color of the tables. It just seems coloring the background does not work. Any help would be appreciated. My site address is http://www.cliffspicer.com/weddings

    Cliff

    <style type="text/css">
    body {
    background-color: #03F;
    }
    </style>

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    <style> tags should not be placed anywhere other than in the document head.

    You should consider using a Child Theme in order to add custom CSS definitions.

  3. cspicer
    Member
    Posted 3 years ago #

    Hi Chip,

    Thanks for the feedback. I really appreciate it. Can you explain the concept of a "Child Theme" further. I am not familiar with this term. I am guessing it is a Theme within a theme but I am not sure how to create such a theme.

    As well, are you saying that CSS should not be added to the HTML section of a post or if I am adding the CSS it should be withing the <head> </head> of this code?

    All the best,

    Cliff

  4. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Codex entry on Child Themes

    Yes, CSS should not be added, via <style> tags, anywhere but in the document head (i.e. inside the <head> tags). If added in the body, it should be added as inline CSS.

  5. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    your theme is using body_class(), so you should be able to target the body background color for the particular post by using the post id; for instance add something like this to style.css of your theme:

    body.postid-542 { background-color: #03F; }

    i think your theme also uses post_class().

    http://codex.wordpress.org/Function_Reference/body_class
    http://codex.wordpress.org/Function_Reference/post_class

  6. cspicer
    Member
    Posted 3 years ago #

    Excellent suggestion alchymyth and Chip. I will work on it and see how I do. I will also read the document links you sent me in detail.

Topic Closed

This topic has been closed to new replies.

About this Topic