Explore options to add back semantic classnames to block wrappers #38719
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.
Metadata
Assignees
Labels
Type
Projects
Status
📢 Not started