-
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
Verse Block: Alignment uses inline styles #15751
Comments
Hi @CreativeDive. Thanks for creating the issue. I hope you don't mind, I changed the title to be more specific. It looks like text alignment works the same across other core blocks I've checked (paragraph, header, possibly others), they also use an inline style. I had a look through some of the history in git, but couldn't find any justifications for an inline style over a class. Pinging @jasmussen, who's very knowledgeable on these matters to see if he has any ideas. |
Thanks for the ping. My knowledge extent here suggests that the person to ask is @ellatrix. She is the master of everything rich text. Ella any thoughts? |
I have a similar issue with paragraphs and all other blocks which apply inline styles in their save function. It makes everything a pain to theme, and the html starts to get really ugly/hacky quick (like a lot of page-builders out there, which is why I prefer Gutenberg). The only things I believe require inline styles are custom attributes like backgrounds, margins and padding. Everything else imho should be class-based as a convention. I'd recommend using a new class like With the new styles being something along the lines of: .aligntextleft { text-align: left }
.aligntextcenter { text-align: center }
.aligntextright { text-align: right } This allows the theme designer to know when an alignment has been applied on the text and style it accordingly. Hopefully someone who has more of a say on the architecture can provide more insight/help. |
I'm proposing a fix which could get applied to all blocks which use text alignment in #16035. |
That's really amazing news @gziolo, and the implementation looks very clean. Hopefully the PR lands soon, and is used as a convention going forward. And we can do away with non-essential inline attributes on all blocks. |
Now that #16035 has landed for Heading block, we should replicate it for Verse as well. |
I opened #16777 which will resolve this issue. |
Currently the verse block get an inline style after selecting a specific alignment.
<pre style="text-align:left" class="wp-block-verse">Content</pre>
This is an unexpected behavior and should work like this:
<pre class="wp-block-verse alignleft">Content</pre>
Without adding the alignment class, I can't set any specific theme side styles for the alignment of verse block.
Is there a reason why you should not add the alignment class to this block type?
The text was updated successfully, but these errors were encountered: