Blog

Add a CSS Class to the Body Tag in Kentico

by Joel Dahlin on November 18, 2015

Add a CSS Class to the Body Tag in Kentico

I often am handed over markup that has the styling of a page based off a css class that has been added to the body tag. If I can't get them to move it to a wrapper class I can do this by using the code snippet below in the Layout of the Page Template.

<script runat="server">
  protected void Page_Load(object sender, EventArgs e)
  {
    Page.DataBind();
    CMS.DocumentEngine.DocumentContext.CurrentBodyClass += " your-class";
  }
</script>

This will append the class to the classes Kentico adds.

#tip

Comments
Blog post currently doesn't have any comments.
 Security code