-
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
Separator Block HTML is completely different in the editor and in the frontend #28964
Comments
I have added my own block using |
This is how I target the separator block. Editor Frontend Hope this helps. |
Thanks @Sandstromer, but I need to target the wrapper in the editor, not the |
The wrapper exists only to define the alignment, so you do your wide or full stuff on the wrapper, then the styling on the hr separator. I'm struggling to think of a use case for targeting a wide/full block where it is only wrapping the separator. |
@Sandstromer All child elements of the block wrapper in the frontend have However, this rule can't be applied in the block editor, because the target separator wrapper element I'm not looking for a CSS hack or workaround, but advising of logic problems because the HTML generated for the editor and the frontend are completely different. The same issue applies to every block, so if it's not addressed, it means that many layouts are simply not possible to achieve in Gutenberg. This issue happens multiple times in every project we develop. |
I agree there is a disconnect between the addition of the I can only say what helped me when I started messing around with the block editor and then going into FSE themes, was to develop first for the editor, then the frontend. |
Thanks @Sandstromer: that's why I have created this issue. It was much easier to code CSS at the beginning of 2019, as the HTML in the editor was much closer to the HTML in the frontend. This is no longer the case, as each new version of WordPress Core introduces more and more problems due to an increasing disparity between the two sets of HTML. If this continues, the amount of extra work required by coding everything twice will mean we'll have to stop using Core and switch back to ACF, as we did until 2018. |
An alternative to using the descendant selector method |
I believe this is the same for almost any block that has alignment of wide or full (the exception being image, which is implemented differently) There's an issue here that's relevant and discusses improving things- #20650 I'd recommend adding feedback to that issue. I'll mark this as a duplicate |
The HTML on the frontend of the website is a simple
hr
with appropriate CSS class names. If the element is set toalignwide
then the appropriate class name is directly on thehr
. This is expected behaviour and allows me to adjust the styling appropriately.In the editor, the
hr
stands alone if it is not set toalignwide
oralignfull
. If it is set toalignwide
oralignfull
, it is then wrapped with adiv
featuring adata-align
attribute. The class namesalignwide
andalignfull
aren't used anywhere.Because the wrapper isn't specific to the separator block (
<div class="wp-block" data-align="wide">
), it cannot be targeted with appropriate CSS styling rules.The text was updated successfully, but these errors were encountered: