-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Using px for root nullifies browser font-size #19460
Comments
I'd tend to support this, FWIW |
But doesn't your screenshot show the exact opposite? |
I... uh... Yes. It totally does. I guess that's what I get for deciding to stick that on at the last second. In an effort to save face a bit, I’ve done a little more digging. Most browsers don’t actually expose the zoom settings on a settings page, but using the hotkeys or view menu to change zoom seems to persist in IE9 and Firefox. Documentation I found on IE11 and Edge seems to indicate those behave similarly. Chrome is a bit of an oddball. Using the view menu or hotkeys is temporary, as I indicated in the text of my original post, but it also allows you to customize zoom AND font size on the settings page (e.g. that screenshot), which is lasting. I guess that does reduce the severity of this issue. But I do think nullifying the font-size setting, at least in Chrome seems off to me. Especially when we seem so close to supporting it. |
The pessimist in me, having seen various unfixable bugs related to non-pinch page zooming, suspects that something would break, but that's just a feeling. I would love to be proven wrong by empirical data. (The other pessimist in me imagines that some designers might arbitrarily hate browsers' default font sizes (or the possibility of the defaults being inconsistent across browsers), but maybe designers are in reality more reasonable than I sometimes feel like they are.) |
By sheer coincidence, an article on this topic was in the Responsive Design Weekly newsletter this morning: http://nicolas-hoizey.com/2016/03/people-don-t-change-the-default-16px-font-size-in-their-browser.html |
Happy to see my article is useful! ;-) |
I absolutely agree that the font-size should not be set on What I don't understand is why we would fix the font-size on root to |
Anyone hip to the details of how setting root font-size prevents user preferences? I'm coming from a place of ignorance here; so forgive me if this sounds asinine, but it seems like it'd be fairly trivial for the browser (or other accessibility tool?) to override the root by multiplying current root font-size value by the percentage the user has specified. It'd be great to be able to continue using |
Sure. This code doesn’t follow the user’s base font-size preference: :root { font-size: 16px; }
h1 { font-size: 1.5em; /* = 24px */ } and this one does: h1 { font-size: 1.5em; /* = might be 24px,
or smaller/bigger depending on user preference */ } Since default browser styles do make use of this user preference, overriding that behavior by using
Indeed the User Agent is free to disregard some if not all your CSS or JavaScript code, so they can offer features such as:
… and that’s about the only one I know of. Other desktop browsers and most or all mobile browsers don’t offer that kind of feature. (Opera used to have several such features before they jumped ship to Blink.) Note that only overriding author styles for the root font-size would be a tad too specific and limited, since author styles can use absolute units for font-size at any step in the document. |
Man, I feel like a dummy--was confused and thought that all root font-size definitions broke user preferences. Thanks for the considerate response @fvsch. I guess I'll just +1 this and propose that, since
Thanks! |
Are there any risks or pitfalls to switching this out for us? If someone wants to submit a PR, I'd love to see some testing across browsers of all our major component. |
There are two possible strategies: // 1. Mandate that $font-size-root should be defined in pixels, always
$font-size-root: 16px !default;
html {
font-size: percentage($font-size-root / 16px);
}
// 2. Mandate that $font-size-root should be a relative value, while allowing
// other units.
$font-size-root: 100% !default;
html {
font-size: $font-size-root;
} The downside of the first solution is that, if users set Downside of the second solution is that users can change
The main risk is if you have components with widths defined in @media (min-width: 640px) {
.modal {
width: 60rem; /* expecting 1rem = 10px */
}
} Use that on a page where |
Opened #21524 for this. |
Doing this makes it breaks users font-size preferences in some browsers (such as Chrome) – see twbs/bootstrap#19460 for more details. We should instead _assume_ the root font-size is 16px - the point being that if it’s not then the text should adjust accordingly.
Doing this makes it breaks users font-size preferences in some browsers (such as Chrome) – see twbs/bootstrap#19460 for more details. We should instead _assume_ the root font-size is 16px - the point being that if it’s not then the text should adjust accordingly.
I know this has been hashed over in the past, but I don't see any discussion about it for v4. Using px for the root font-size invalidates the user's font-size settings in the browser. This really should be defined in em/rem/%. The thought that bootstrap will be stripping away this functionality from users on a large portion of the web is unsettling.
Yes, I know that zoom still works, but this is a temporary, per-tab setting. Users with low vision are the one's most likely to need to increase their font size, and they will need it increased all the time, permanently. The shouldn't have to zoom in again every time they open a new tab.
Rems are broadly supported now. Use those on the root element. I see no benefit to favoring pixels on the root, particularly when the framework uses ems and rems liberally everywhere else.
The text was updated successfully, but these errors were encountered: