Problem/Motivation

You should be able to use id, class, etc., attributes on <hr> tags if those attributes are available via Styles dropdown or have been added to the Source editing "Manually editable HTML tags" field.

Steps to reproduce

  1. Edit a Text format. Ensure Horizontal rule and the Source editing CKEditor plugin icons are present in the active toolbar config.
  2. Add hr.class-name|Classname to Styles tab field of the Text format, then move focus out of the field. See error message:
    The <hr> tag is not yet supported by the Style plugin.
  3. Add <hr class id> to Source editing tab's "Manually editable HTML tags" field of the Text format. See error message:
    The following attribute(s) can optionally be supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Style (<hr class>).
  4. Edit a page containing a Ckeditor field. Switch into Source editing mode and add id or class attributes to an HR tag. Switch out of source editing mode. Attributes are stripped.

Proposed resolution

  • Add support for HR tag to Style plugin (support class attribute).
  • Add configurations to prevent CKEditor from stripping class attributes from HR tag.
  • Add configurations to prevent CKEditor from stripping any attributes from HR tag that are allowlisted by Source editing "Manually editable HTML tags" field.

Remaining tasks

User interface changes

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

Support for HR tags has been added to CKEditor 5 Styles dropdown; allowlisted attributes will no longer be stripped from HR tags when switching out of Source editing mode.

Issue fork drupal-3384819

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cobasa created an issue. See original summary.

cobasa’s picture

Issue summary: View changes
cobasa’s picture

Issue summary: View changes
slussier’s picture

Same for me. +1

joelpittet’s picture

Has this ever worked? I can't do that using core's filter either, I think this is a ckeditor5 issue

duttonma’s picture

Status: Active » Closed (works as designed)

I think I can see the problem here.

You have shown the values that you have set in 'Manually editable HTML tags' under source editing but, assuming that you have enabled this filter ('Limit allowed HTML tags and correct faulty HTML - editable tag list'), you haven't shown the values that you have set in 'Allowed HTML tags'.

I suspect that you have added 'hr class id' to source editing but you haven't added it to 'Allowed HTML tags' and the two work in conjunction. If it isn't in 'Allowed HTML tags' then it won't show when you view the node and that's it !

jasonmacer’s picture

I can confirm that I have


enabled, as when I try to add it in: Home >Administration >Configuration >Content authoring>Text formats and editors, I get this error: The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Horizontal line (

).

I also do not have the "Limit allowed HTML tags and correct faulty HTML" enabled, yet I am still not able to set a class id an


element

Drupal Core Version: 10.2.4

irodriguez’s picture

Has this ever been resolved? I am still experiencing this problem. Drupal version 10.2.5

franknoel’s picture

Status: Closed (works as designed) » Active

Same issue on 10.3.6, this has not been resolved.

jsweetack’s picture

This is not a problem with your module, it's a problem with Drupal and CKEditor 5. I don't have your module installed on my site, I just happened to see this page when looking for a solution for this issue.

I'm really not understanding the move to CKEditor 5 with all these issues.

I purposefully didn't upgrade last year from 4 because of problems like this. I waited until now, and after a year, still so many issues. The "limit allowed tags" previous feature completely tripped me up right off the bat. After figuring out I had to turn it off completely just to make the site work correctly, the first tag I try to add a class to is a simple horizontal rule element.

And it doesn't work. The content editors of my site use these things all over the place. How am I supposed roll out this upgrade knowing it will break all the styled horizontal rules of any content if any of the editors make and save any changes to said content?

So you can imagine my frustration when I find there's actually an issue for this one individual element.

How much faith do you think I have that the rest of this system is going to work?

Absolutely ridiculous that CKEditor 5 was green lit to go into Drupal core given all the problems STILL not resolved.

madhaze’s picture

Having same issue. Any fix for this.

- Style tab - when trying to add `hr.class-name` get:
`Error Message - The <hr> tag is not yet supported by the Style plugin.`

- Source Editing tab - tried `<hr class>` and get :
`Error message - The following attribute(s) can optionally be supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Style (<hr class>).`

So not working as expected from #6 - Allowed HTML isn't editable in ckeditor 5.

madhaze’s picture

is there a way we can make a patch based on https://github.com/ckeditor/ckeditor5/issues/12973

It looks like HR support was added to CKeditor https://github.com/ckeditor/ckeditor5/pull/17895 in tag v44.3.0 https://github.com/ckeditor/ckeditor5/releases/tag/v44.3.0
Can we update ckeditor version?

Although i'm not sure if that allows for hr to be added to Style tab?

alex.bukach’s picture

jwilson3’s picture

Project: CKEditor 5 Allowed HTML » Drupal core
Version: 1.0.x-dev » 11.x-dev
Component: Miscellaneous » ckeditor5.module

If HR support for classes is to be added to Drupal, it needs to be implemented in Drupal core first. The error messages in #7 and #11 related to HR tags in Source Editing settings and in Styles settings come from core.

Current status:

  1. CKE5 version 44.3 added support for preserving attributes on HR tags.
  2. Drupal is already using 47.1 as of mid October 2025. See #3555560: Update CKEditor 5 to 47.1.0.
  3. If the HR icon and Source icons are enabled in text format settings, Drupal core's CKE config still strips classes on HR tags when switching out of Source mode.
  4. Furthermore, <hr id class> cannot be added to Source Editing "Manually editable HTML tags" with the following error message:
    The following attribute(s) can optionally be supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Style (<hr class>).
  5. Drupal core's CKE Styles settings tab still doesn't support HR tags with error message:
    The <hr> tag is not yet supported by the Style plugin.

    .

jwilson3’s picture

Issue summary: View changes
jwilson3’s picture

Issue summary: View changes
jwilson3’s picture

Issue summary: View changes

meeni_dhobale made their first commit to this issue’s fork.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

jwilson3’s picture

Reading the "Steps to reproduce" on #3410100, it seems like it is specifically about using the "Manually editable HTML tags" feature. Part of this issue indeed talks about that, but this issue's scope is larger. Perhaps this issue should be centered around step 2 from this Issue summary's Steps to reproduce; namely:

2. Add hr.class-name|Classname to Styles tab field of the Text format, then move focus out of the field. See error message:
The <hr> tag is not yet supported by the Style plugin.

jacobupal changed the visibility of the branch 3384819-cant-add-class to hidden.

jacobupal’s picture

Version: main » 11.x-dev

jacobupal’s picture

Status: Active » Needs review

Seems like we now only need to delete <hr>, from core/modules/ckeditor5/src/Plugin/Validation/Constraint/StyleSensibleElementConstraintValidator.php and it can then have a class applied with the Styles plugin!

Made an MR with a test too - I copied the format of the other tests.

jacobupal’s picture

StatusFileSize
new159.82 KB
new114.52 KB

Screenshots from the tugboat:

In the editor (css was set in my browser):
HR styled before saving

After saving (same css running in my browser, not the environment):
HR Styled and rendered after saving

That said, you can still go to the node where I did this and inspect the hr element in your devtools to verify the class is applied.

smustgrave’s picture

Version: 11.x-dev » main
Status: Needs review » Needs work

Issues need to land in main first

jacobupal’s picture

Status: Needs work » Needs review

Cheers! I've rebased now so the issue branch targets main.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative
StatusFileSize
new27.12 KB

Confirmed with the MR as a patch
1. I could go into any text formatter using Style dropdown and add a style for hr tag. Before I was blocked
2. On the node edit form I get the Style dropdown enabled when focus is on the hr tag
3. Confirmed it saved without issue

working

No additional feedback.

kmonty’s picture

+1 on RTBC. We patched this on a project two weeks ago and it is working without issue.

alexpott’s picture

Version: main » 11.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 70240abad43 to main and d013c156581 to 12.0.x and 175d2c59fb6 to 11.x and ea3b361d193 to 11.5.x. Thanks!

Backported to 11.5.x as a low risk bug fix. Nice to finally get this done.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed ea3b361d on 11.5.x
    fix: #3384819 Can't add class attribute to hr
    
    By: cobasa
    By: jwilson3...

  • alexpott committed 175d2c59 on 11.x
    fix: #3384819 Can't add class attribute to hr
    
    By: cobasa
    By: jwilson3...

  • alexpott committed d013c156 on 12.0.x
    fix: #3384819 Can't add class attribute to hr
    
    By: cobasa
    By: jwilson3...

  • alexpott committed 70240aba on main
    fix: #3384819 Can't add class attribute to hr
    
    By: cobasa
    By: jwilson3...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.