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

Respect user agent font sizing #1280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

toastal
Copy link
Contributor

@toastal toastal commented Mar 12, 2024

While the typical user agent font size is 16px, this value is configurable by the user. Much of this project is built in rem unit which are relative to the base which can be helpful to accessibility. However, when a base size is set to px the user agent’s font size is no longer respected. This value is a percentage to match the previous px value (i.e. 8.25 ÷ 16).

Prior arts typically use 62.5% as it makes rems effectively ⅒ the px size which makes the math of converting much easier. Rather than touching all rem values, this fix merely is changing the single base value.

1

Footnotes

  1. Please consider giving up MS GitHub or offering a non-proprietary, non-US-corporate-controlled mirror for this free software project.
    I wish to delete this Microsoft account in the future, but I need more projects like this to support alternative methods to send patches & contribute.

@edhelas
Copy link
Member

edhelas commented Mar 18, 2024

Do you actually have a source that says that using px in <html> tend to break the user agent configuration ? Browsers are doing conversion between all the time and I see lots of tutorials that explains to set the base value in px (16px by default).

@toastal
Copy link
Contributor Author

toastal commented Mar 19, 2024

My eyes are not great as they used to be so I noticed immediately as I have the base font size bumped a hair. This one is easy to test just setting the HTML as a % as this patch suggests & adjust the user agent font size such as about:preferences#fontsGroup in a Gecko-based browser. Trying not to appeal to authority, but I have been doing front-end dev for over a decade.

Seeming genesis of 62.5% body: https://snook.ca/archives/html_and_css/font-size-with-rem

https://www.freecodecamp.org/news/override-root-font-size-for-a-better-user-experience/

https://medium.com/@jagadishkamuni/respecting-font-size-preferences-rems-and-62-5-base-font-size-aleksandr-hovhannisyan-f0473d6c8410

While the typical user agent font size is `16px`, this value is
configurable by the user. Much of this project is built in `rem` unit
which are relative to the base which can be helpful to accessibility.
However, when a base size is set to `px` the user agent’s font size is
no longer respected. This value is a percentage to match the previous
`px` value (i.e. 8.25 ÷ 16).

Prior arts typically use 62.5% as it makes `rem`s effectively ⅒ the `px`
size which makes the math of converting much easier. Rather than
touching all `rem` values, this fix merely is changing the single base
value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants