Support » Themes and Templates » CSS and Post Backbround Color

  • 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>

Viewing 5 replies - 1 through 5 (of 5 total)
  • Chip Bennett

    (@chipbennett)

    Theme Review Admin

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

    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

    Chip Bennett

    (@chipbennett)

    Theme Review Admin

    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.

    Michael

    (@alchymyth)

    Forum Moderator

    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

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘CSS and Post Backbround Color’ is closed to new replies.