Magento – custom css file loads last in magento 2

magento2

directory structure.

app / design / frontend / Kidzie / theme / Magento_Theme / layout /default_head_blocks.xml
app / design / frontend / [vendor] / [theme] / web / css /custom.css

I need to load custom.css file at last of all css files. so my custom style should apply over default magento 2's css.

enter image description here

<css src="css/custom.css" order="100"/> Gives me error that order is not a valid property.

Best Answer

Magento2 doesn't manage the CSS order, order="" property doesn't exists,

The available CSS attributes are:

  • defer
  • ie_condition
  • charset
  • hreflang
  • media
  • rel
  • rev
  • sizes
  • src
  • src_type
  • target
  • type

I have some workaround to put the css at the end of all. the trick is to add media="all".

<css src="css/custom.css" media="all" />
Related Topic