Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Node ID Class

41 sites Security covered Drupal 10–11
View on drupal.org

This module allows you to add custom CSS IDs and classes to the body tag and individual node wrappers. You can use dynamic tokens like node ID, title, bundle, and author to create flexible theming and custom frontend behavior.

The Node ID Class module for Drupal enables site builders to assign custom CSS IDs and classes to the <body> element and individual node wrappers. These can include dynamic tokens such as {node_id}, {node_title}, {bundle}, and {node_author_uid}, allowing flexible theming, unique layouts, or custom frontend behavior.

Requirements

  • Drupal Version: This module requires Drupal 10 or higher.
  • Additional Modules: No additional contributed modules are required.

Installation

  • Download the Node ID Class module.
  • Install using Composer:

    composer require drupal/node_id_class
  • Or manually place the module in your modules/custom directory. See:

    Drupal module installation guide
  • Enable the module via the Extend page in the Drupal admin interface or using Drush:

    drush en node_id_class

Configuration

After enabling the module, a new Node ID Class fieldset will appear on each content type’s edit page (e.g., admin/structure/types/manage/article). Within this fieldset, you can configure the following:

  • CSS Body ID: Applied to the <body> element on full node pages. Supports tokens: {node_id}, {bundle}, {node_title}, {node_author_uid}. Example: body-id-{node_id}-{bundle}-{node_title}
  • CSS Body Class(es): Applied to the <body> element. Supports multiple classes separated by spaces. Example: body-class-{node_id}-{bundle}
  • CSS Node Class(es): Applied to the node wrapper in all view modes and listings (e.g., Views). Supports multiple classes separated by spaces. Example: node-class-{node_id}-{bundle}-{node_title}

Dynamic Tokens

  • {node_id} – Node ID
  • {node_title} – Node title (converted to a URL-friendly slug)
  • {bundle} – Content type machine name
  • {node_author_uid} – Node author’s user ID

Tokens are sanitized and escaped automatically to prevent invalid markup or XSS vulnerabilities.

Similar Projects

Troubleshooting & FAQ

  • Custom classes not appearing? Ensure the node is displayed in a full-page view mode and your theme prints $attributes and $content_attributes.
  • Body ID or classes not showing? Verify that the settings are saved for the correct content type.
  • Tokens are not replaced? Tokens only work when viewing a node page.
  • Why is HTML not allowed in the fields? HTML is stripped for security, preventing XSS attacks and invalid CSS.

Support

Please post bug reports, feature requests and support requests to the Node ID Class module issue queue. If you met any problems with this module - feel free to create an issue.

Depends on

Dependencies of the latest stable release

  • node Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Feb 2025
Latest release
8 months ago
Releases (12 mo)
2
Maintenance
Slowing

Release Timeline

Releases

Version Type Core Release date
1.1.3 Stable 10–11 Dec 9, 2025
1.1.2 Stable 10–11 Dec 9, 2025
1.1.x-dev Dev 10–11 Feb 2, 2025
1.1.1 Stable 8–11 Feb 2, 2025