Skip to content

Do you plan to lower the Specificity of the CSS selector for the block to 0?Β #55829

Open
@ddryo

Description

Description

I have a question about future policy.

Previously, styles for blocks had high Specificity, so to override them, the CSS loaded in the theme was loaded later than "wp-block-library-css".

add_action( 'wp_enqueue_scripts', function() {
	// wp-block-library
	wp_enqueue_style( 'wp-block-library' );

	// styles of my theme
	wp_enqueue_style( 'theme-style', '.../style.css' );
} );

However, over the past few years, with each update, the selector has been adjusted.

Even in this 6.4 release, some code had the level of Specificity lowered from 0-2-0 to 0-0-0.

/* 6.3 */
.wp-block-preformatted.has-background {
    padding: 1.25em 2.375em;
}

/* 6.4 */
:where(.wp-block-preformatted.has-background) {
    padding: 1.25em 2.375em;
}

This made it lose out to the reset css in the theme.

/* reset css in theme */
* {
    padding: 0;
}

The p.has-background etc. still seemed to be intact, but do you plan to lower their Specificity level to 0 in the future as well?

If so, then you will need to make a major revision to the CSS loaded in your theme and plugins.

Step-by-step reproduction instructions

Sorry, just a question.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

Metadata

Assignees

No one assigned

    Labels

    CSS StylingRelated to editor and front end styles, CSS-specific issues.[Type] QuestionQuestions about the design or development of the editor.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions