Search A2Z 24

Question : How to add css class on body in Magento2

I am trying to add a css class on body tag but not able to find any file, from where the body tag is rendered.

I need to add one css class on body tag in PLP such as others are coming > page-with-filter page-products page-layout-2columns-left myclasshere

in previous version(Magento 1.x) below was the xml code to add class on body.

<reference name="root">
 <action method="addBodyClass"><classname>my-profile</classname></action>

I tried using this but it didn't worked.

I need to add one class with page-layout-2columns-left template only.

asked May 23, 2017

1 Answers

Dispalying 1 to 1 of 1 |

In your layout file, you need to add an attribute to the body tag, like this:

    <attribute name="class" value="my-css-class"/>
See comments (0) | Comment
Answered More than a year ago
Dispalying 1 to 1 of 1 |

Write your Answer write code <pre class="brush: xml">---code---</pre>

Login as a member to access answering block !! click-here

Reveal Modal Goodness

This is a default modal in all its glory, but any of the styles here can easily be changed in the CSS.

This is just a simple modal with the default styles, but any type of content can live in here. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi quis sem vel enim eleifend tristique. Etiam tincidunt faucibus pharetra.