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
- Edit a Text format. Ensure Horizontal rule and the Source editing CKEditor plugin icons are present in the active toolbar config.
- Add
hr.class-name|Classnameto 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. - 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>). - Edit a page containing a Ckeditor field. Switch into Source editing mode and add
idorclassattributes 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | Screenshot 2026-09-28 at 3.07.47 PM.png | 27.12 KB | smustgrave |
| #26 | hr-styled-rendered.jpg | 114.52 KB | jacobupal |
| #26 | hr-styled-editor.jpg | 159.82 KB | jacobupal |
| ckeditor-hr.jpg | 86.62 KB | cobasa |
Issue fork drupal-3384819
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:
- 3384819-remove-hr-styling-restriction
changes, plain diff MR !17024
- 3384819-cant-add-class
compare
Comments
Comment #2
cobasa commentedComment #3
cobasa commentedComment #4
slussier commentedSame for me. +1
Comment #5
joelpittetHas this ever worked? I can't do that using core's filter either, I think this is a ckeditor5 issue
Comment #6
duttonma commentedI 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 !
Comment #7
jasonmacer commentedI 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
Comment #8
irodriguez commentedHas this ever been resolved? I am still experiencing this problem. Drupal version 10.2.5
Comment #9
franknoel commentedSame issue on 10.3.6, this has not been resolved.
Comment #10
jsweetack commentedThis 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.
Comment #11
madhaze commentedHaving 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.
Comment #12
madhaze commentedis 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
hrto be added to Style tab?Comment #13
alex.bukach commentedSee https://www.drupal.org/project/drupal/issues/3523018.
Comment #14
jwilson3If 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:
<hr id class>cannot be added to Source Editing "Manually editable HTML tags" with the following error message:Stylessettings tab still doesn't support HR tags with error message:.
Comment #15
jwilson3Comment #16
jwilson3Comment #17
jwilson3Comment #20
prudloff commentedThis looks like a duplicate of #3410100: [10.2 regression] CKEditor 5 breaks when "Source"/Source editing button is added and "Manually editable HTML tags" are specified.
Comment #21
jwilson3Reading 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:
Comment #23
jacobupal commentedComment #25
jacobupal commentedSeems like we now only need to delete
<hr>,fromcore/modules/ckeditor5/src/Plugin/Validation/Constraint/StyleSensibleElementConstraintValidator.phpand 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.
Comment #26
jacobupal commentedScreenshots from the tugboat:
In the editor (css was set in my browser):

After saving (same css running in my browser, not the environment):

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.
Comment #27
smustgrave commentedIssues need to land in main first
Comment #28
jacobupal commentedCheers! I've rebased now so the issue branch targets main.
Comment #29
smustgrave commentedConfirmed 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
No additional feedback.
Comment #30
kmonty+1 on RTBC. We patched this on a project two weeks ago and it is working without issue.
Comment #31
alexpottCommitted 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.