I have 1 specific page in Magento 2.2.2, that I'd like CSS on. In my _extend.less file, if I include the CSS there, it'll effect other pages that have the same classes. I don't want that to happen.

Thank you.


Steps to achieve this :

  1. Go to that page & Inspect element.
  2. Search for body tag, right click on body tag - select 'copy selector' under 'copy' option.
  3. In _extend.less, paste the copied selector let's say selector be- body.question-page new-topbar

body.question-page new-topbar{ // write your css inside }

  1. compile and run grunt to update changes.
  2. Test it.
| improve this answer | |
  • I tried that, it still loads on every other page. Is there another way? – Mohammed Joraid May 1 '19 at 11:39

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.