The Large, Small, and Dynamic Viewports

There are some changes being made regarding viewport units. The additions — which are part of the CSS Values and Units Level 4 specification — define several viewport sizes: the Large, Small, and Dynamic Viewport.

Thanks to these additions we will finally be able to solve that “100vh in Safari on iOS” issue.


Table of Contents

  1. The Large, Small, and Dynamic Viewports

  2. But, why? Can’t we just use the workaround?
  3. The catch
  4. Going Logical
  5. Browser Support
  6. In Closing


Update 2021.07.14: Some parts of this post have been rewritten to include the latest CSSWG changes regarding these units.

Update 2021.07.23: 🎉 The proposed changes have landed in the official spec by now. This post has been updated accordingly.


# The Large, Small, and Dynamic Viewports

The CSSWG has defined several extra Viewport Sizes and accompanying Viewport-relative Units (spec), in addition to the already existing vw/vh/vmin/vmax ones.

# The Large Viewport

The Large Viewport is the viewport sized assuming any UA interfaces (such as the address bar) that are dynamically expanded and retracted to be *retracted*. It has the l-prefix, so units are lvh / lvw / lvmin / lvmax.

For example: 100lvh stands for 100% of the large viewport height.

# The Small Viewport

The Small Viewport is the viewport sized assuming any UA interfaces that are dynamically expanded and retracted to be *expanded*. It has the s-prefix, so units are svh / svw / svmin / svmax.

For example: 100svh stands for 100% of the small viewport height.

# The Dynamic Viewport

The Dynamic Viewport is the viewport sized with *dynamic consideration of any UA interfaces*. It will automatically adjust itself in response to UA interface elements being shown or not: the value will be anything within the limits of 100lvh (maximum) and 100svh (minimum).

Its prefix is d, so the units are dvh / dvw / dvmin / dvmax.

👉 You’ll want these Dynamic Viewport Units to have a UI that auto-stretches as the UA interface changes. 100dvh will automatically adapt itself.


# But, why? Can’t we just use the workaround?

You might ask yourself why we can’t simply rely on this workaround instead of introducing all these new units:

body {
  height: 100vh;

@supports (-webkit-touch-callout: none) {
  body {
    height: -webkit-fill-available;

Whilst the workaround above does achieve what we want, it only results in “full viewport height” for body. This is because -webkit-fill-available stretches items out inside their enclosing element — here the viewport. For some deeply nested elements that wouldn’t work, as -webkit-fill-available applied on them will look at their parent element — not the viewport. With 100dvh we can easily achieve what we want.

Above that you can’t use -webkit-fill-available to size something “half the size of the enclosing element”, as you can’t use -webkit-fill-available within calc(), e.g. height: calc(-webkit-fill-available * 0.5) is invalid CSS. Even if this were to be allowed one day, we’d again run into the issues when wanting to size a deeply nested element relatively to the viewport (see paragraph above).

So yes, we definitely do need these new Viewport Units 🤩


# The catch

As mentioned before these new proposed l*/s*/d* units are additions to the already existing vw/vh/vmin/vmax units. With this, the CSSWG chose to keep these “old” units ambiguous: vw/vh/vmin/vmax have no explicit definition, and it’s totally up to the UA (browser) to define how they behave. Some browsers will have vh behave like lvh (like the current Safari does), while other browsers can make vh behave like dvh.

What also is up to the UA to choose, is the behavior of the Dynamic Viewport. Some browsers may update its value immediately while the interface is changing, whereas other browsers may only update the value after the UI has transitioned … the spec is fine with both.

The UA is not required to animate the dynamic viewport-percentage units while expanding and retracting any relevant interfaces, and may instead calculate the units as if the relevant interface was fully expanded or retracted during the UI animation.

Above that things like on-screen keyboards are not taken into account. For that we have the upcoming Virtual Keyboard API.


# Going Logical

Additionally the spec now also defines logical units, and thus talks about vi/dvi/svi and vb/dvb/svb which are the inline and block size respectively of the large/dynamic/small viewport. A small but very welcome addition.


# Browser Support

At the time of writing no browser supports these units. You can track their progress in these Issues:

Update 2021.10.06: 👀 There’s some movement in the WebKit/Safari issue, with an initial patch being committed. Will we see this land as an experimental feature in one of the next Technology Preview releases?

Update 2021.11.15: 🛳 Support for these news units has shipped with Safari Technology Preview 135. Expect them to be publicly available in the next Safari release.

This pen below will indicate whether your browser supports CSS Dynamic Viewport Units or not:

See the Pen
CSS Dynamic Viewport Units test
by Bramus (@bramus)
on CodePen.


# In Closing

It feels great to see things finally move in this area I must say, as the reported WebKit bug about 100vh not being 100vh-as-we-expect-it-to-be dates back from 2015, and the relevant CSSWG Issue from 2019.

As a final consensus on these viewport additions has been reached, I hope that the upcoming Safari 15 — which alters the viewport extensively as you scroll up/down — will make work to include these additions on top of their already supported env(safe-area-inset-*) values (e.g. height: calc(100vh - env(safe-area-inset-bottom));).


To help spread the contents of this post, feel free to retweet the announcement tweet:


🔥 Like what you see? Want to stay in the loop? Here's how:

🗣 This post originally was a set of tweets.

About the author

Bramus is a Freelance Web Developer from Belgium. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Join the Conversation


  1. It would probably make sense to define what “UA” stands for before using it throughout your entire article. Since even Google won’t give a first-page definition for “ua interface”, it might be wise to refrain from using unknown acronyms…

    1. Good call. I’ve added an abbr element there to say what UA stands for: “User Agent”. That itself basically translates to the browser (the app) itself.

  2. I don’t get the diffence between dvh and svh. Where is the difference between dynamic and small?
    We will see if the main problem – Apple – will incorporate the new technique very fast or as slow as ever. If the latter, we will have to deal with the problem for the next let’s say 5 years.

    1. It’s a value that automatically adjust itself in response to UA interface elements being shown or not: the value will be anything within the limits of 100vh (maximum) and 100svh (minimum).

      Hope this explains it better. I’ve updated the post to include this snippet.

  3. Do these new units help at all with the 100vw causing horizontal scrollbar issue?

Leave a comment

Leave a Reply to Jens Grochtdreis Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.