CSS and Post Backbround Color (6 posts)

  1. cspicer
    Posted 5 years ago #


    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


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

  2. Chip Bennett
    Theme Review Admin
    Posted 5 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
    Posted 5 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,


  4. Chip Bennett
    Theme Review Admin
    Posted 5 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. Michael
    Forum Moderator
    Posted 5 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().


  6. cspicer
    Posted 5 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