cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling the order of CSS files

Controlling the order of CSS files

Is there any way to ensure that my child themes CSS loads BEFORE that of it's parent theme. I'm adding the CSS file in `default_head_block.xml`.

 

There seems to be a few work arounds to make the CSS file load further down the page, but not before an existing CSS file.

 

Surely with all the configuration options magento and xml provide, there must be a way? 

 

Thanks.

2 REPLIES 2

Re: Controlling the order of CSS files

Hi @mattgreenfield,

 

Maybe I miss understand the problem but if you have a child theme the right behavior is to be loaded AFTER the parent theme. Right?

Isn't that the idea with hierarchy?

Re: Controlling the order of CSS files

Well yes, I see what you mean. I have child styles merging with parent styles in less, that makes styles.css.

 

The problem is that my child theme also wants to add a CSS file BEFORE styles.css. So that styles.css can override. Because styles.css is in the xml of my parent theme, it outputs first.

 

The odd thing for me is that we can't use 'before=""' in the xml like we can for blocks and containers. That's how I'd expect it to work anyway!