You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-values] Use of 100vw is causing pointless horizontal scrollbars on some websites #6026
Windows users and macOS users that have enabled “Show scroll bars: Always” are seeing pointless horizontal scrollbars on some websites that use the 100vw value. One common use-case for 100vw are full-width elements:
If you can’t check for yourself and are not sure what a pointless horizontal scrollbar is, watch this video that I posted on Twitter.
The authors of these websites are most likely not aware of this issue because they developed the website on macOS with default (overlaid) scrollbars, where this issue does not occur.
As a result, many people are experiencing these pointless horizontal scrollbars, and a fair share of these people probably find them annoying (raises hand 🙋♂️).
Does the Working Group consider this to be a problem that requires an intervention? Are there any proposed features or changes that could help make this problem go away over time?
See #1766. Not very easy to do them auto-magically work because it'd be cyclic (declarations using vw units could cause scrollbars to appear which would change how vw would resolve).
It'd be feasible to make them work with with overflow: scroll, but only Firefox implemented that and nobody else did so we removed that...
@emilio I did not suggest to make changes to viewport units. I asked if the Working Group plans to do something about the problem of pointless horizontal scrollbars that appear on some websites, a problem that I predict will not go away on its own. Does this problem require an intervention or can it be ignored?
Reacted by Elisabetta, Brent Kimmel, Kai, Bert Zhang, Carlos Roldán, Reyadul Islam, Mikaël Sévigny and Conor Kuo
Not very easy to do them auto-magically work because it'd be cyclic (declarations using vw units could cause scrollbars to appear which would change how vw would resolve).
Percentages are not cyclic now, so why couldn't vw (or new unit) be equivalent to "percentage of root element"? Every single time I've used vw units, I don't care one little bit how wide the viewport is if part of it is being covered by a scrollbar. I only care what part of the viewport I can "draw" the element in without causing horizontal scrolling. If my element is direct child of the body, this is super easy, 100% (or just don't specify any width is element is block).
.one and .two-child should resolve as same exact width regardless of vertical scrollbar being visible or not. Can we make this happen somehow?
Reacted by James Dawson, Veronica Watt, Gyles Fohl, Benjamin Strauß, Markus Lohmeier, Dan Boulet, Ramrami Mohamed, Daniel Kaspo, itsHel, Oskar Olsson and 8 more
Percentages are not cyclic now, so why couldn't vw (or new unit) be equivalent to "percentage of root element"?
Because percentages aren't resolved until layout, while viewport units are. More generally, content inside the viewport can't affect the viewport size, but it can affect whether the root element shows scrollbars or not.
Reacted by Daniel Kaspo, jonjohnjohnson, Misael Taveras and Seungrok Yoon
Well, that is one option. Note that that would behave subtly differently than the current viewport units. Adding layout-time relative units is relatively hard (no pun intended) compared to adding units that resolve at computed-value time like vh / vw. Though definitely not impossible.
@emilio I don't know too much about the actual rendering processes, but this description makes it seem like it would be easier to calculate as there wouldn't need to be any tree traversal to compute, there would just be the one root node to be concerned with. But I understand there has to be more to it.
Up to this point we've calculated which nodes should be visible and their computed styles, but we have not calculated their exact position and size within the viewport of the device---that's the "layout" stage, also known as "reflow."
To figure out the exact size and position of each object on the page, the browser begins at the root of the render tree and traverses it.
The body of the above page contains two nested div's: the first (parent) div sets the display size of the node to 50% of the viewport width, and the second div---contained by the parent---sets its width to be 50% of its parent; that is, 25% of the viewport width.
Very confusing as their use of "viewport width" isn't the same as the vw unit, which you would reasonably assume.
Activity
emilio commentedon Feb 22, 2021
See #1766. Not very easy to do them auto-magically work because it'd be cyclic (declarations using vw units could cause scrollbars to appear which would change how vw would resolve).
It'd be feasible to make them work with with overflow: scroll, but only Firefox implemented that and nobody else did so we removed that...
simevidas commentedon Feb 22, 2021
@emilio I did not suggest to make changes to viewport units. I asked if the Working Group plans to do something about the problem of pointless horizontal scrollbars that appear on some websites, a problem that I predict will not go away on its own. Does this problem require an intervention or can it be ignored?
emilio commentedon Feb 22, 2021
I guess we can reopen, but it's hard to say from a web engine when a scrollbar is "useless" if there's content overflowing.
felipeerias commentedon Feb 24, 2021
Related: #5254
felipeerias commentedon Feb 26, 2021
Also related: #5232
coreyworrell commentedon Feb 26, 2021
Percentages are not cyclic now, so why couldn't
vw(or new unit) be equivalent to "percentage of root element"? Every single time I've usedvwunits, I don't care one little bit how wide the viewport is if part of it is being covered by a scrollbar. I only care what part of the viewport I can "draw" the element in without causing horizontal scrolling. If my element is direct child of the body, this is super easy,100%(or just don't specify any width is element is block)..oneand.two-childshould resolve as same exact width regardless of vertical scrollbar being visible or not. Can we make this happen somehow?emilio commentedon Feb 26, 2021
Because percentages aren't resolved until layout, while viewport units are. More generally, content inside the viewport can't affect the viewport size, but it can affect whether the root element shows scrollbars or not.
coreyworrell commentedon Feb 26, 2021
@emilio Okay so why not create a new unit (or modify
vw) that resolves at layout like percentage?emilio commentedon Feb 26, 2021
Well, that is one option. Note that that would behave subtly differently than the current viewport units. Adding layout-time relative units is relatively hard (no pun intended) compared to adding units that resolve at computed-value time like vh / vw. Though definitely not impossible.
bramus commentedon Feb 26, 2021
Also related: #4329
coreyworrell commentedon Feb 26, 2021
@emilio I don't know too much about the actual rendering processes, but this description makes it seem like it would be easier to calculate as there wouldn't need to be any tree traversal to compute, there would just be the one root node to be concerned with. But I understand there has to be more to it.
Very confusing as their use of "viewport width" isn't the same as the
vwunit, which you would reasonably assume.johannesodland commentedon Mar 17, 2021
Also related: #4691
72 remaining items
[css-values-4] Make unconditional scrollbars on the root finally affe…
fantasai commentedon Mar 11, 2024
Edits are done for the WG resolution in #6026 (comment) and filed follow-up wrt
dv*etc in #10059[css-values-4] Add viewport unit tests for scrollbars
[css-values-4] Add viewport unit tests for scrollbars
Bug 1884841 [wpt PR 45036] - [css-values-4] Add viewport unit tests f…
Bug 1884841 [wpt PR 45036] - [css-values-4] Add viewport unit tests f…
[css-values-4] Add viewport unit tests for scrollbars
Bug 1884841 [wpt PR 45036] - [css-values-4] Add viewport unit tests f…
[viewport units] Enable SmallerViewportUnits by default