-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Explore targeting global styles to the body element instead of :root #27478
Comments
Everything is inside the
As a concept that makes perfect sense to me... Adding padding controls to all blocks - though possible - would result in too much noise. +1!
I would love for us to build a "site" block which would implement a css-grid a-la-#18600, but if there is a "root"/"site" block, how would themes have total control of where it is? It would - by necessity - wrap everything, possibly being the first - and only - element inside |
Yes, every HTML content should be inside the body, but although not correct browsers still render elements placed outside the body. I guess that's not a case we should worry about given that if that's the case third party code is doing something unexpected. @mtias, @youknowriad, @nosolosw is this issue still something we should give a try? Make global styles target body instead of:root? |
yeah, I think this makes sense. |
Many existing solutions inside and outside the WordPress ecosystem use |
Hi there @markhowellsmead I'm curious to know what kind of ecosystem usage is relying not the Personally, I don't mind moving some CSS variables back to the For the CSS variables it's another story but I don't see it as a big argument for it either. What's the reason for this since everything is inside |
As I've mentioned above, the W3C recommendation is that CSS custom properties adhere to the same principles as all other CSS rules: that definitions begin on the Regarding layout rules: applying these should certainly begin at the block container, not the body. Until now, various solutions have used I think it's a bad idea for core to enforce a class name for the block container in the frontend, as this will add to the existing issues where core CSS is too specific already. (Sometimes too specific to override easily.) |
One specific case of the need for custom properties to be applied to |
Just as a quick clarification: having re-read your comment, I think you're primarily looking at this with regards to the editor. This issue is possibly more relevant to the rules which are auto-generated for the frontend of the website. I can see that applying the custom properties to the block root container in WordPress Admin could make sense, but it's important to note that some themes contain CSS rules for elements which are outside the block root element (e.g. the block sidebar panels), which lie outside |
In order to have global styles padding, it may make sense to target the global styles to the body element.
We may have some issues with this e.g: if there are elements outside the body, like overlays, etc. So we may need to target presets using :root and styles like padding using the body which adds more complexity.
This exploration may also show that padding should not be allowed globally but just for a container block. Or it may show the need for a site block, so themes have total control of where the root block is.
The text was updated successfully, but these errors were encountered: