Allow double underscores to pass through drupal_clean_css_identifier as per new CSS standards

Created on 1 June 2013, about 12 years ago
Updated 15 August 2025, 8 days ago

Problem/Motivation

Drupal’s new CSS coding standards recommend a naming convention for classes which requires the use of double-underscores as separators in certain cases. However, Drupal currently processes some classes internally using drupal_clean_css_identifier(), which replaces all underscores with dashes.

Proposed resolution

Allow double underscores to pass through drupal_clean_css_identifier untouched, if the allow_css_double_underscores variable is enabled. Because many modules rely on the current behavior of this function in order to generate standard dash-separated class names from php strings such as field_name (and this does not need to change), we should for the time being retain the existing behaviour for single underscores. πŸ› Overly aggressive transliteration in drupal_clean_css_identifier removes underscores from classes Closed: duplicate exists to discuss altering the treatment of single underscores.

Update august 2025: About transforming a single underscore into a dash, see πŸ› Views row class filtering underscore to dash on direct input Active .

Remaining tasks

None.

User interface changes

None.

API changes

None.

Related Issues

#1995272: [Meta] Refactor module CSS files inline with our CSS standards β†’
πŸ› Overly aggressive transliteration in drupal_clean_css_identifier removes underscores from classes Closed: duplicate

πŸ› Bug report
Status

Fixed

Version

7.0 ⚰️

Component

theme system

Created by

πŸ‡¨πŸ‡¦Canada ry5n

Live updates comments and jobs are added and updated live.
  • mobile

    Issue related to Drupal on mobile devices.

  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024