Custom Body Class is a lightweight Drupal module that allows site administrators and content editors to add custom CSS classes to the <body> element of individual content pages and content types.
Adding a custom body class makes it easier to apply page-specific or content-type-specific styling without requiring changes to the site's theme templates.
Features
- Add custom CSS classes to the
<body>tag of individual content pages. - Add custom CSS classes based on content type.
- Apply page-specific styling without modifying theme templates.
- Useful for creating targeted layouts and styling for specific content types or pages.
- Simple configuration with minimal overhead.
Usage
After enabling the module, configure the custom body class for the required content type or individual content page.
The configured class is added to the HTML <body> element when the corresponding page is rendered.
This allows theme developers and site builders to target specific pages or content types with CSS.
For example:
<span class="hljs-selector-class">.my-custom-page</span> { <span class="hljs-comment">/* Page-specific styles */</span> }
Use Cases
Custom Body Class can be useful when you need to:
- Create a unique layout for a specific content type.
- Apply page-specific CSS.
- Add styling variations for landing pages.
- Customize the appearance of selected content pages.
- Differentiate sections of a website without creating separate themes or templates.
Project information
- Project categories: Content display, Content editing experience
1,942 sites report using this module
- Created by harshita29 on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.





