• Hi.

    I am creating a child theme for on a local server. This parent theme uses a lot of specific selectors such as

    div#container_wrap {}
    div#header ul#nav {}
    div.page_heading {}

    I am doing a fair bit of modifications so using “!important” is not an ideal solution. What is the best way to override these div#ids without resorting to !important? Specific selectors are used extensively in the parent stylesheet.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • if you use the same specific selectors in the child theme’s stylesheet, there should be no need for !important

    as this is a pure css question, you might get better replies in a css forum like http://csscreator.com/forum

    or, you could use more specific selectors.. something like:

    body div#container_wrap{}

    but, yes, @alchymyth is right in that if the child theme is loaded right, you should have no problem using the same css selectors as the parent theme.

    Thread Starter codered007

    (@codered007)

    Thanks for the response.

    The child stylesheet seems to be loading correctly. I can get new css rules to apply but just cant override those specific selectors from the parent theme even when I copy it exactly.

    The theme does have a custom css option within the backend wordpress interface. The overrides work when I place the code there without the need for !important. Could this custom option be causing the blocks?

    @alchymyth thanks for the link. I will check it out.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    It’ll be easier for us to debug the issue of why your CSS changes are not applying if we can access the webpage with it.

    there are cases when the parent theme loads further stylesheets after style.css;

    example:
    Twenty Eleven – when the dark theme option is selected;

    if you rather totally work from within the child theme, you might need to load your own options.css or whatever.css and make sure to enqueue it after any other stylesheets of the parent theme.

    http://codex.wordpress.org/Function_Reference/wp_enqueue_style

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to override specific selectors in parent theme?’ is closed to new replies.