Support » Fixing WordPress » child theme not always overrides parent

  • Resolved fprotani


    Hello everybody, I’m new to this forum.

    I decided to build my own website ( although I’m not familiar at all with html or CSS. I’m using Responsive theme and I created a child theme to customise it, as suggested by the experts in this forum.
    I’m having trouble with the front page. I’ve been trying to get rid of the white border at the top and bottom of the picture and to move it closer to the navigation menu. Fiddling with Chrome’s Inspect element tool, I’m able to sort out the issue and place the picture where I want it to be, but when I copy and paste the CSS command with the new values into the child theme’s stylesheet nothing happens. All the modified margins and paddings seem to go back to the default parent theme values. I’m clearly doing something wrong but I haven’t got a clue what it could be. Any help, please?

Viewing 8 replies - 1 through 8 (of 8 total)
  • CSS applies rules in a certain order. Normally, the last rule found is the one used. So, if your rule is not the last one found, it will have no effect unless you override the order by adding ‘!important’ to the rule, like this:

    #featured-image {
        margin: 0 !important;

    Even then, if there is another rule with ‘!important’ that is found later that one will override yours.

    Hi vtxyzzy,
    thanks for your post. I’ve tried to add !important as you suggested but nothing happened.

    I do not see the code when I view the site. Please leave the change in place so we can view it

    The code I’m trying to edit is this one:

    [ 406 lines of code moderated, that’s just way too much. For that many lines of code please use instead. ]

    I hope that helps.

    There is no need to post the code. Put the lines I suggested at the end of you child theme’s style.css and leave them there.

    I put the code you posted at the end of the child theme’s style.css but the top margin keeps going back to 40px.

    I still do not see the lines at the end of the child theme’s style.css. Please put them there and leave them.

    Thanks for your patience vtxyzzy. It works now and I know what I was doing wrong. I’ve been customising the child theme by writing codes in the Custom CSS Style section of Responsive theme options, whereas as soon as I put the code you suggested in the CSS editor it worked. What I don’t understand now is why some codes worked in the Custom CSS style and some others didn’t.
    Thanks a lot for your help

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘child theme not always overrides parent’ is closed to new replies.