Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonathan Seligsohn
23,116 PointsChild Theme Development - Override Parent Styles - WordPress
Is there a better way to override parent styles when working on a child theme, other than using "!important"? Supposedly just writing a more specific selector should do the trick, but that's not working for me. I'm using a free template - Typal. When viewing the "head" of the page, it appears that the child theme style.css is loaded before the parent's css. Is this how it should be? If I understand my CSS correctly, a stylesheet that's lower down on the page will override previous styles (assuming they have same level of specificity, which is the case).
While googling I saw something about wp_head() not being at the top of the header.php file. Another solution was to wp_dequeue_style on the parent's css and then reload the style with a lower priority. Does any of that make sense?
1 Answer
Zac Gordon
Treehouse Guest TeacherTry moving wp_head() to right before the closing head tag and see if that helps. If not, I would think the theme developer would have some suggestions here on how to fix. Worse case you would have to use functions.php to unhook and rehook the styles, but hopefully the first two options should help.
Jonathan Seligsohn
23,116 PointsJonathan Seligsohn
23,116 PointsThanks. Checking again, it could be I didn't have the write css selectors in place.