-
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
Font size: Why not using relative units (em or %, for example)? #6454
Comments
Here is list of affected files I've found:
|
Thanks for exploring this. Historically, discussion has been back and forth on relative and other variations of style sizes. Ultimately it comes down the predictability problems with measures like em and %, even with the slightly more precise rem. I'll leave open for other inputs but this is something consciously decided to do because of those issues. |
@karmatosed A lot of themes actually allow for font size setup. This is usually set on the HTML root or body. If a user decides to rise the font size on their website from default |
Surely, I'll wait for other opinions. Thanks for such fast reply @karmatosed! |
I think Relative sizes are certainly better, but it could create unexpected issues for themes (especially older ones) built without relative units in mind. I expect this is further down the road, but as the core themes (and arguably |
Thanks for your opinion!
Well, this can be turned the other way around too: using pixel unit sizes will create issues with more recent themes using scale-able relative units. 😃 For me this is still win for relative units ;) |
Hi @webmandesign, It seems like changing the current implementation is unlikely at this time. If you'd like to make a stronger case, I'd suggest performing and sharing some research on:
|
What do you think about adding a setting for this? |
@amirmp3 @danielbachhuber You should at least let developers omit the "size" parameter in add_theme_support('editor-font-sizes'), so that no inline styles with fixed pixel values are present in the editor. Or maybe a custom function / filter / hook for developers to remove them? The problem is, they simply break spacings & font sizes on mobile previews if you decided to use relative units and have a smaller root font size on mobile devices. At the moment you'd have to overwrite your own CSS rules with !important - this feels redundant and can lead to problems in the cascade. My current solution is to calculate the corresponding pixel values matching my em's in the stylesheet and then set them in editor_font_sizes. But this is tidious, error-prone and still breaks mobile previews. Without those inline styles everything would be fine for me. |
Issue Overview
Using Gutenberg 2.7.0
From what I can see right now, the Paragraph, Quote and Pullquote blocks are using pixel units for setting up font sizes. This doesn't seems to be correct approach and I suggest we use relative units there, such as
em
or%
instead. Relative units should be much more compatible with any theme.Current Behavior
Example styles from current
gutenberg/core-blocks/paragraph/style.scss
:Expected Behavior
Use relative units:
Possible Solution
Change the font sizes in relevant
.scss
files toem
units calculated with16px
base font size.The text was updated successfully, but these errors were encountered: