Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global styles: Lower selector specificity for declaring CSS properties (CSS variables) #40042

Closed
webmandesign opened this issue Apr 5, 2022 · 3 comments
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json

Comments

@webmandesign
Copy link
Contributor

Description

Currently WordPress global styles declare CSS properties/variables on body selector:

body {
	--wp--preset--color--black: #000000;
	...
}

This seems to be quite high specificity as themes and plugins can not use :root or html now to override those CSS variables.

It would be great if WordPress CSS variables in global styles are declared on :where(:root) selector, which provides low enough specificity:

:where(:root) {
	--wp--preset--color--black: #000000;
	...
}

That way also :root selector used in themes and plugins can override WordPress global styles CSS variables with ease.

There is really no need to set such high specificity (meaning using body selector) for declaring default CSS variables in my opinion.

Step-by-step reproduction instructions

Not applicable here.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 5.9+

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

@markhowellsmead
Copy link

See also #35840.

@Mamaduka Mamaduka added the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Apr 5, 2022
@skorasaurus skorasaurus added the CSS Styling Related to editor and front end styles, CSS-specific issues. label Apr 5, 2022
@skorasaurus
Copy link
Member

Hi,

This overlaps quite a bit with #35840 ; mind if I close this out and keep track of progress in that issue?

@webmandesign
Copy link
Contributor Author

@skorasaurus Sure, go ahead. I'll post a comment at #35840. Sorry for duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
Projects
None yet
Development

No branches or pull requests

4 participants