I have installed magento 2.1.7 with custom theme. Now I want to add a custom css file for modifying theme css.

In that case what's the best practice to add css file.

  1. Create a .less file and include it
  2. Create a .css file and include it in layout

You can do using below code in your layout:

    <css src="Namespace_YourModule::css/custom.css"/>

You have to delete folders



create custom.less In custom.less file file import all less files as per your requirment.


open theme.js file and add your less file under the theme Make sure don't give extensions when you add a file.

For Example

alive: {
        area: 'frontend',
        name: 'Alive/alivetheme',
        locale: 'en_US',
        files: [
        dsl: 'less'

deploy static content using command: php bin/magento setup:static-content:deploy

check you css changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.