Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Body Attributes

No security coverage Under active development

Body Attributes lets you add CSS classes and HTML attributes to your website's HTML and body elements based on rules you create. You can target specific pages or content types and define exactly which attributes or classes to apply, offering granular control over your site's styling and behavior.

Body Attributes provides a flexible way to add CSS classes and HTML attributes to page elements in Drupal based on configurable rules and conditions.

Features

  • Rule-Based Targeting: Create multiple rules with custom priorities (weights).
  • Flexible Zones: Target the html tag, body tag, or specific structural elements like header, main, and footer.
  • Custom Selectors: Use CSS selectors to target specific elements on the page beyond standard structural tags.
  • Visibility Conditions: Apply attributes based on:
  • Request Path: Target specific pages or patterns (e.g., /blog/*).
  • Node Type: Apply attributes only to specific content types (e.g., "Article" or "Product").
  • Developer Friendly: Built using modern Drupal standards (PHP 8.1 Attributes, Strict Typing, and Service-oriented architecture).

How it Works

  • Define a Rule: Navigate to Configuration > User Interface > Body Attributes.
  • Choose a Zone: Select where you want the attribute applied.
  • Set Attribute & Value: Define the class or HTML attribute (e.g., data-mode="dark").
  • Set Conditions: Determine which pages or content types trigger the rule.
Drupal 10–11

Ask your assistant about Body Attributes

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Mar 2026
Latest release
7 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Slowing

Releases

Version Type Core PHP Release date
1.0.0 Stable 10–11 Mar 13, 2026
1.0.x-dev Dev 10–11 Mar 13, 2026