Skip to content

Text highlight/inline background color is hardcoded making style changes difficult #49332

Closed

Description

@Andrew-Starr

What problem does this address?

Currently when highlighting text and selecting a pre-defined background color, the background color is hardcoded inline.

The text color is added with the relevant class, so why not the background also?

Example with white text on a black background:

This is some <mark style="background-color:#000000" class="has-inline-color has-white-color">highlighted text</mark> here

If a theme defines various styles with different color palettes, upon switching style the hardcoded background colors do not change visually to match the new style, and currently the only way to change the background color is to find each instance and manually change it for all highlighted text.

What is your proposed solution?

Use e.g. has-black-background-color CSS class instead of hardcoding the background color.

Activity

  1. added
    CSS StylingRelated to editor and front end styles, CSS-specific issues.
    on Mar 24, 2023
  2. chrismademe commented on Mar 25, 2023

    @chrismademe

    I ran into this yesterday, can anyone shed any light on why it's an inline style as opposed to a class?

  3. Andrew-Starr commented on Mar 27, 2023

    @Andrew-Starr
    Author

    Don't know why class was not used but there was comment - #34680 (comment) - from a year ago asking the same question, but it seems to have been missed.

  4. youknowriad commented on Oct 17, 2026

    @youknowriad
    Contributor

    Thanks for reporting this, @Andrew-Starr. The same problem (Highlight saving the background color as an inline hex value instead of the palette class or variable) is tracked in #70025, which already has a PR in progress. I'm closing this one as a duplicate so the discussion stays in one place. Please follow #70025.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CSS StylingRelated to editor and front end styles, CSS-specific issues.[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions