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 trial

WordPress WordPress Theme Development The WordPress Loop Adding the Loop to the index.php File

Eugen Oanta
Eugen Oanta
5,657 Points

Why does the position of enqueue script matters inside the functions.php?

So I have positioned the enqueue_style function for the main_css, more specifically the style.css at the top of the enqueue scripts list. This cause some weird looking things on the site. I knew I positioned it like that voluntarily and I changed it afterwards and all was fixed. My question is: Why does it matter for WP to load style.css last? it doesn't seem to have a dependency with the other style sheets. for the info in the video example , the teacher places it on the bottom of the enqueue style list.

Thank you :)

4 Answers

Dale Severude
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 Points

Style.css overrides the other style sheets with your custom changes. If style.css is first, then the other style sheets would override most of your changes and they will disappear. Due to the cascading nature of style sheets, the order in which they are loaded is very important.

Sanjeev Veloo
Sanjeev Veloo
4,713 Points

I think it does. I shifted the load normalise.css right to the top so it loads before foundation. And the page looks like the index.html example. Anyone else verify this?

    function wpsv_theme_styles(){

        wp_enqueue_style( 'normalize_css', get_template_directory_uri() . '/css/normalize.css');
        wp_enqueue_style( 'foundation_css', get_template_directory_uri() . '/css/foundation.css');
        wp_enqueue_style( 'googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic');
        wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css');

    }

its to do with over riding as Dale mentions.

I believe which ever style sheet is on top overrides the ones below?