Magento 2.2.6 – How to Add Custom CSS File

cssmagento2.2.6styles

I tried to add some custom styles in Magento but I couldn't find out how to do this.

How do I add the custom css stylesheets in magento-2.2.6?

Best Answer

You need to follow the below steps:

Step 1: Create default_head_blocks.xml like below:

app/design/frontend/[vendor]/[theme]/Magento_Theme/layout/default_head_blocks.xml

Step 2: Andd create local.css like below

app/design/frontend/[vendor]/[theme]/web/css/local.css

Step 3: Add the below code to default_head_blocks.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/Module/etc/module.xsd">
  <head>
    <css src="css/local.css" />
  </head>
</page>
Related Topic