Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Configuration Language Lock 1.0.2 Minor update available for module config_language_lock (1.0.2). Release: Canvas Override 1.0.1 Minor update available for module canvas_override (1.0.1). Release: Media Remote Image 8.x-1.2 Minor update available for module media_entity_remote_image (8.x-1.2). Release: IDNA Convert Service (punycode) 2.0.4 Minor update available for module idna (2.0.4). Release: Bootstrap Cloud 7.1.3 Minor update available for theme bootstrap_cloud (7.1.3). Release: Token Browser 1.0.2 Minor update available for module token_browser (1.0.2). Release: Varbase Project 11.0.8 Minor update available for module varbase_project (11.0.8). Release: Media Remote Image 2.0.0-beta1 First beta version released for module media_entity_remote_image (2.0.0-beta1). Usage Milestone: Term CSV Export Import Module term_csv_export_import crossed 1,000 active installs. Security Coverage: Module Scout Module module_scout now has official Drupal security advisory coverage.

Body Attributes

No security coverage Drupal 10–11
View on drupal.org

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.

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
5 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Slowing

Releases

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