Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There are some styles in my parent theme that I would simply remove from the stylesheet if I was not using a child theme. Obviously, I do not want to remove them from the parent css, but is there a way to effectively "remove" the styles using my child theme?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

The only way to "remove" styles from the parent theme is to override them in your child theme's css.

For example if you have the following declaration in your parent theme:

.someclass{
    width: 200px;
    float: left;
 }

You can override the width and float by declaring the following in your child theme:

.someclass{
    width: auto;
    float: none;
}
share|improve this answer

Effectively, yes. Unless I am misunderstanding your question, this is just basic CSS specificity. I assume you are wanting to use most of the CSS from the parent theme, but only some of it is not wanted, since the CSS isn't, by default, loaded from the parent theme.

All the normal rules of overriding or increasing specificity apply. The simplest (but most brute force) method is to just create rules that use !important to override the rules you don't want. Otherwise you should just rely on the rule cascade and specificity to properly target the things you want and set the styles you want.

There is nothing built into wordpress to filter, cut, delete or remove bits of CSS from a parent theme, if that's what you are asking.

share|improve this answer

I don't think there is a way, only workarounds.

Edit:

Explanation: By creating a child theme you are, by definition, loading the CSS of the parent theme. Therefore I don't see a way you could exclude some parts of that CSS. The only effective way would be to override it. The most straightforward way would be to use the selectors and rules you want to override, and set them to new or default values. Since child theme CSS is lower up in the "cascade" of styles than the parent CSS, there shouldn't be a need for "!important" statements and such.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.