Drupal is a registered trademark of Dries Buytaert
Search API Solr 4.4.0 Minor update available for module search_api_solr (4.4.0). Page Manager 8.x-4.0 Major update available for module page_manager (8.x-4.0). Trash 3.1.0-beta2 New beta version released for module trash (3.1.0-beta2). Commerce AutoSKU 3.0.1 Minor update available for module commerce_autosku (3.0.1). Custom Field 4.0.10 Minor update available for module custom_field (4.0.10). Alternative login ID & display names 2.0.12 Minor update available for module alt_login (2.0.12). EntityReference UUID 3.0.1 Minor update available for module entity_reference_uuid (3.0.1). LocalGov Publications Importer 1.1.1 Minor update available for module localgov_publications_importer (1.1.1). Configuration Override Warn 8.x-1.6 Module config_override_warn updated after 10 months of inactivity (8.x-1.6). Table Alternate Rows Module table_altrow crossed 1,000 active installs.

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.

Activity

Total releases
2
First release
Mar 2026
Latest release
4 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

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