Repository navigation
Description
Description
There is a major inconsistency in how inline style attributes are handled within synchronized patterns that have overrides enabled.
The rich text "Highlight" tool in the block editor creates a <mark> tag with an inline style attribute (e.g., style="background-color:..."). However, when a user overrides the content of a block containing this markup within a synced pattern, the style attribute is stripped out upon saving, while the class attribute is preserved.
The core inconsistency is :
- why does the editor provide a tool that generates inline styles if the pattern override system is designed to strip them ?
- the behavior should be consistent: either never add inline styles, or always preserve them ?
Step-by-step reproduction instructions
- Create a new synchronized pattern.
- Insert a Heading block. In the heading's text, use the "Highlight" tool to color a portion of the text. To create colored text without a background, one common method is to set the highlight background to transparent, which results in a
<mark>tag with an inline style - Ensure that overrides are enabled for the Heading block within the pattern.
- Save the synchronized pattern.
- Insert this pattern into a new page or post.
- Modify the text content of the heading. For example, change "Title with color" to "A new title with color".
- Save the page and inspect the code of the overridden heading block.
<!-- wp:group {"metadata":{"name":"Custom title section"},"style":{"spacing":{"padding":{"bottom":"var:preset|spacing|50"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="padding-bottom:var(--wp--preset--spacing--50)">
<!-- wp:heading {"metadata":{"name":"Title","bindings":{"__default":{"source":"core/pattern-overrides"}}}} -->
<h2 class="wp-block-heading">
Title
<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-orange-700-color">with color</mark>
</h2>
<!-- /wp:heading -->
</div>
<!-- /wp:group -->Actual behavior
The style="background-color:rgba(0, 0, 0, 0)" attribute is stripped from the mark tag, while the class attribute is correctly preserved. The resulting code is :
<h2 class="wp-block-heading">Title <mark class="has-inline-color has-orange-700-color">with color</mark></h2>Expected behavior
The mark tag within the overridden heading should preserve both its class and its inline style attribute. The code should look like this :
<h2 class="wp-block-heading">Title <mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-orange-700-color">with color</mark></h2>Screenshots, screen recording, code snippet
Color menu
Pattern
Pattern in a page (back office)
Pattern in page front end
Environment info
- WordPress Version : 6.8.1
- Gutenberg Plugin : Not active
- Theme : custom hybrid theme
- Theme json version : V3, https://schemas.wp.org/wp/6.6/theme.json
- Browser : All
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure




Activity
talldan commentedon Jun 9, 2025
Thanks for reporting this, it's not designed to do this, unfortunately it's a bug. It should preserve the content. It's a really unusual bug, since the color is preserved.
patil-vipul commentedon Jun 9, 2025
@webexpr-dhenriet The issue can be replicated in the latest version of Gutenberg (21.0.0-rc.1).

Frontend:

Will update here with a patch.
webexpr-dhenriet commentedon Jun 9, 2025
@talldan @patil-vipul thanks for the feedback ;)
dhananjaykuber commentedon Nov 12, 2026
I tested this on trunk and it looks fixed by #84213. The style was removed when the override was rendered, because WP_Block::replace_html() passes the override through wp_kses_post(), and safecss_filter_attr() dropped any value using rgba(). #84213 lets CSS color functions through kses, and with it the override renders as expected. Removing that filter brings the bug back. The Core change is tracked in Trac #66387 for WordPress 7.3, so I think this can be closed once that lands.