Child theme css not overriding parent Child theme css not overriding parent wordpress wordpress

Child theme css not overriding parent


This problem is most likely caused be CSS selector specificity. Essentially, the parent css rule is more narrowly tailored to hit that element than the rule you're assigning. You can get your css to take over by using rules that are more specific than the parent css, or use the same rules, in which case yours will take priority, as it is loaded later.


Try updating your function to

<?php    function my_theme_enqueue_styles() {       wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );      wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style') );    }    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );?>

Afterwards please provide a screenshot of what is actually being loaded in your console.

Not sure why you created a variable of the parent-style, but you can keep using that of course.

Hope this helps


Try adding

 @import url("..twentyseventeen/style.css");

above .entry title at the top of your child stylesheet. This is required along with your Template name. Hope this helps.