Skip to content

Explore options to add back semantic classnames to block wrappers  #38719

Open

Description

Description

As noted here, and here the move to random class names for applying layout styling in the likes of the Buttons block has removed the ability of themes/plugins to easily target elements based on layout.

For instance, in WP 5.8 a button block that was centrer aligned would have a class assigned to indicate this:

<div class="wp-block-buttons is-content-justification-center"></div>

but in 5.9, a button block that is center aligned just has a random classname assigned to apply these styles:

<div class="wp-container-620589d3d9565 wp-block-buttons"></div>

Ideally this should be done in a way that does not involve serialising these classnames in the saved block content, so the Style engine seems like the best place to explore adding these back as this can enable it to be done at runtime from the current block semantics in both the editor and frontend.

Additional discussion has taken place here and here, in relation to the value of semantic classnames to allow themes to override styles.

This needs to be balanced out with a desire to not expose too many classnames that may not be intended as a permanent API, but which theme authors may assume they can depend on.

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

Metadata

Assignees

No one assigned

    Labels

    CSS StylingRelated to editor and front end styles, CSS-specific issues.[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    • Status

      📢 Not started

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions