{"id":30172,"date":"2017-06-12T23:01:04","date_gmt":"2017-06-12T15:01:04","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=30172"},"modified":"2018-04-09T16:51:15","modified_gmt":"2018-04-09T08:51:15","slug":"css-viewport-units-vw-vh-wmin-vmax","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/","title":{"rendered":"Guide to CSS Viewport Units: vw, vh, vmin, vmax"},"content":{"rendered":"<p><strong>Viewport-percentage lengths<\/strong>, or <strong>viewport units<\/strong> as they are more frequently referred to, are responsive CSS units that allow you to define dimensions <strong>as a percentage of the width or the length of the viewport<\/strong>. Viewport units can be quite useful in cases in which other responsive CSS units, such as percentages, are <strong>hard to make work<\/strong>.<\/p>\n<p>Although <strong>W3C\u2019s documentation<\/strong> <a href=\"https:\/\/www.w3.org\/TR\/css3-values\/#viewport-relative-lengths\" target=\"_blank\" rel=\"nofollow\">on viewport units<\/a> contains everything that can be put into theory, it\u2019s not very verbose. So, in this article, we\u2019ll have a look at how these CSS units <strong>work in practice<\/strong>.<\/p>\n<p class=\"recommended_top\">\n\t\t\t\t\t<strong>Read Also:<\/strong>\u00a0\n\t\t\t\t\t<a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/css-grid-layout-fr-unit\/\">Guide to CSS Grid Layout Fr Unit<\/a>\n\t\t\t\t<\/p>\n<h2>Viewport height (<code>vh<\/code>) & viewport width (<code>vw<\/code>)<\/h2>\n<p>W3C <strong><a href=\"https:\/\/www.w3.org\/TR\/css3-values\/#vh\" target=\"_blank\" rel=\"nofollow\">defines viewport<\/a><\/strong> as \u201csize of the initial containing block\u201d. In other words, viewport is the area <strong>contained within the browser window<\/strong> or any other viewing area on a screen.<\/p>\n<p>The <strong><code>vw<\/code> and <code>vh<\/code> units<\/strong> stand for the percentage of the width and height of the actual viewport. They can take a value <strong>between 0 and 100<\/strong> according to the following rules:<\/p>\n<pre>\r\n100vw = 100% of viewport width\r\n1vw = 1% of viewport width\r\n\r\n100vh = 100% of viewport height\r\n1vh = 1% of viewport height\r\n<\/pre>\n<h3>Differences to percentage units<\/h3>\n<p>So, how are viewport units different from percentage units? Percentage units <strong>inherit the size of their parent element<\/strong> while viewport units don\u2019t. Viewport units are always calculated as the <strong>percentage of the viewport size<\/strong>. As a result, an element defined by viewport units can exceed the size of its parent.<\/p>\n<h3>Example: Full-screen sections<\/h3>\n<p><strong>Full-screen sections<\/strong> are probably the most widely-known use cases of viewport units.<\/p>\n<p>The <strong>HTML is quite simple<\/strong>; we just have <strong>three sections under each other<\/strong> and we want each of them to <strong>cover the whole screen<\/strong> (but not more).<\/p>\n<pre>\r\n&lt;body&gt;\r\n  &lt;section class=\"section-1\"&gt;&lt;\/section&gt;\r\n  &lt;section class=\"section-2\"&gt;&lt;\/section&gt;\r\n  &lt;section class=\"section-3\"&gt;&lt;\/section&gt;\r\n&lt;\/body&gt;\r\n<\/pre>\n<p>In the CSS, we use <code>100vh<\/code> as a <code>height<\/code> value and <code>100%<\/code> as <code>width<\/code>. We don\u2019t use the <code>vw<\/code> unit here as by default, <strong>scrollbars are also added<\/strong> to the viewport size. So, if we used the <code>width: 100vw;<\/code> rule a <strong>horizontal scrollbar<\/strong> would appear at the <strong>bottom of the browser window<\/strong>.<\/p>\n<pre>\r\n* {\r\n  margin: 0;\r\n  padding: 0;\r\n}\r\nsection {\r\n  background-size: cover;\r\n  background-position: center;\r\n  width: 100%;\r\n  height: 100vh;\r\n}\r\n.section-1 {\r\n  background-image: url('https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/img1.jpg');\r\n}\r\n.section-2 {\r\n  background-image: url('https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/img2.jpg');\r\n}\r\n.section-3 {\r\n  background-image: url('https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/img3.jpg');\r\n}\r\n<\/pre>\n<p>On the gif demo below, you can see that <code>vh<\/code> is <strong>truly a responsive unit<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/fullscreen-background.gif\" width=\"850\" height=\"565\" alt=\"Fullscreen sections\"><\/figure>\n<p>According to the <a href=\"https:\/\/www.w3.org\/TR\/css3-values\/#viewport-relative-lengths\" target=\"_blank\" rel=\"nofollow\">W3C docs<\/a>, the aforementioned <strong>horizontal scrollbar issue<\/strong> can be solved by adding the <code>overflow: auto;<\/code> rule to the root element. This solution <strong>only works partially<\/strong>, though. The horizontal scrollbar, indeed, disappears but <code>width<\/code> is <strong>still calculated based on the viewport width<\/strong> (the sidebar included), so the elements will be slightly larger than they should be.<\/p>\n<p>I would say, I wouldn\u2019t dare use the <code>vw<\/code> unit on <strong>sizing full-screen elements<\/strong> because of this reason. We don\u2019t even need it, as the <code>width: 100%;<\/code> rule works perfectly. With fullscreen layouts, the real challenge has always been how to <strong>set a proper height value<\/strong> and the <code>vh<\/code> unit gives a brilliant solution for that.<\/p>\n<h3>Other use cases<\/h3>\n<p>If you are interested in <strong>other use cases <code>vw<\/code> and <code>vh<\/code><\/strong> Lullabot has a <a href=\"https:\/\/www.lullabot.com\/articles\/unexpected-power-of-viewport-units-in-css\" target=\"_blank\">great article<\/a> that lists a <strong>handful of real-life examples<\/strong> (with Codepen demos), such as:<\/p>\n<ul>\n<li>Fixed-ratio cards.<\/li>\n<li>Keeping an element shorter than the screen.<\/li>\n<li>Scaling text.<\/li>\n<li>Breaking out of the container.<\/li>\n<\/ul>\n<p>Opera.dev also has a <a href=\"https:\/\/dev.opera.com\/articles\/css-viewport-units\/\" target=\"_blank\">short tutorial<\/a> on how you can take leverage of the <code>vw<\/code> unit in <strong>creating responsive typography<\/strong>.<\/p>\n<p>You can\u2019t only use viewport units on the <code>width<\/code> and <code>height<\/code> properties but on any other one. For instance, you can <strong>set the size of paddings and margins<\/strong> using the <code>vw<\/code> and <code>vh<\/code> units, too.<\/p>\n<h2>Viewport min (<code>vmin<\/code>) & viewport max (<code>vmax<\/code>)<\/h2>\n<p>The <code>vmin<\/code> and <code>vmax<\/code> units allow you to access the <strong>size of the smaller or the larger side<\/strong> of the viewport, according to the following rules:<\/p>\n<pre>\r\n100vmin = 100vw or 100vh, whichever is smaller\r\n1vmin = 1vw or 1vh, whichever is smaller\r\n\r\n100vmax = 100vw or 100vh, whichever is larger\r\n1vmax = 1vw or 1vh, whichever is larger\r\n<\/pre>\n<p>So, in case of a <strong>portrait orientation<\/strong>, <code>100vmin<\/code> is equal to <code>100vw<\/code>, as the viewport is <strong>smaller horizontally than vertically<\/strong>. For the same reason, <code>100vmax<\/code> will be equal to <code>100vh<\/code>.<\/p>\n<p>Similarly, in case of a <strong>landscape orientation<\/strong>, <code>100vmin<\/code> is equal to <code>100vh<\/code>, as the viewport is <strong>smaller vertically than horizontally<\/strong>. And, of course, <code>100vmax<\/code> will be equal to <code>100vw<\/code> here.<\/p>\n<h3>Example: Make hero texts readable on every screen<\/h3>\n<p>The <code>vmin<\/code> and <code>vmax<\/code> units are much less widely-known than <code>vw<\/code> and <code>vh<\/code>. However, they can be excellently used as a <strong>substitute for orientation <code>@media<\/code> queries<\/strong>. For instance, <code>vmin<\/code> and <code>vmax<\/code> can come in handy when you have elements that may look strange <strong>at different aspect ratios<\/strong>.<\/p>\n<p>The New Code has a <a href=\"https:\/\/thenewcode.com\/1137\/MinMaxing-Understanding-vMin-and-vMax-in-CSS\" target=\"_blank\">great tutorial<\/a> in which they discuss how you can <strong>keep hero text readable<\/strong> on every screen, using the <code>vmin<\/code> unit. Hero texts are prone to look <strong>too small on mobile and too big on large monitors<\/strong>.<\/p>\n<p>Here is the main idea of their solution:<\/p>\n<pre>\r\nh1 {\r\n  font-size: 20vmin;\r\n  font-family: Avenir, sans-serif;\r\n  font-weight: 900;\r\n  text-align: center;\r\n}\r\n<\/pre>\n<p>In the <a href=\"https:\/\/codepen.io\/dudleystorey\/full\/ALWrXZ\/\" target=\"_blank\" rel=\"nofollow\">Codepen demo<\/a>, you can check out how <code>vmin<\/code> solves the readability problem of hero texts. Access the \u201cFull Page\u201d view on Codepen, then <strong>resize your browser window<\/strong> both horizontally and vertically to see how the hero text changes.<\/p>\n<p><iframe height=\"289\" scrolling=\"no\" title=\"vMin for Hero Text\" src=\"https:\/\/codepen.io\/\/dudleystorey\/embed\/ALWrXZ\/?height=289&theme-id=0&default-tab=result&embed-version=2\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\">See the Pen <a href=\"https:\/\/codepen.io\/dudleystorey\/pen\/ALWrXZ\/\" rel=\"nofollow\">vMin for Hero Text<\/a> by Dudley Storey (<a href=\"https:\/\/codepen.io\/dudleystorey\" rel=\"nofollow\">@dudleystorey<\/a>) on <a href=\"https:\/\/codepen.io\" rel=\"nofollow\">CodePen<\/a>. <\/iframe><\/p>\n<h2>Browser support<\/h2>\n<p>As you can see on the <a href=\"https:\/\/caniuse.com\/#search=vw\" target=\"_blank\">CanIUse chart<\/a> below, <strong>browser support is relatively good<\/strong> for viewport units. However, keep in mind that some versions of IE and Edge don\u2019t support <code>vmax<\/code>. Also, iOS 6 and 7 <a href=\"https:\/\/github.com\/scottjehl\/Device-Bugs\/issues\/36\" target=\"_blank\">have an issue<\/a> with the <code>vh<\/code> unit, <strong>which was fixed in iOS 8<\/strong>.<\/p>\n<figure><a href=\"https:\/\/caniuse.com\/#search=vw\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/browser-support-viewport-units.jpg\" width=\"800\" height=\"438\" alt=\"Browser support for viewport units\"><\/a><\/figure>\n<p class=\"note\"><strong>Read Also:<\/strong> <a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/css-units\/\">A Look Into CSS Units: Pixels, EM, and Percentage<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Viewport-percentage lengths, or viewport units as they are more frequently referred to, are responsive CSS units that allow you to define dimensions as a percentage of the width or the length of the viewport. Viewport units can be quite useful in cases in which other responsive CSS units, such as percentages, are hard to make&hellip;<\/p>\n","protected":false},"author":146,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[507,4501],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Guide to CSS Viewport Units: vw, vh, vmin, vmax - Hongkiat<\/title>\n<meta name=\"description\" content=\"Viewport-percentage lengths, or viewport units as they are more frequently referred to, are responsive CSS units that allow you to define dimensions as a\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Guide to CSS Viewport Units: vw, vh, vmin, vmax\" \/>\n<meta property=\"og:description\" content=\"Viewport-percentage lengths, or viewport units as they are more frequently referred to, are responsive CSS units that allow you to define dimensions as a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-12T15:01:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-04-09T08:51:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/fullscreen-background.gif\" \/>\n<meta name=\"author\" content=\"Anna Monus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anna Monus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/\"},\"author\":{\"name\":\"Anna Monus\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/a601053a0ab457901e00cdc83bd5359e\"},\"headline\":\"Guide to CSS Viewport Units: vw, vh, vmin, vmax\",\"datePublished\":\"2017-06-12T15:01:04+00:00\",\"dateModified\":\"2018-04-09T08:51:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/\"},\"wordCount\":812,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-viewport-units-vw-vh-wmin-vmax\\\/fullscreen-background.gif\",\"keywords\":[\"CSS\",\"CSS Tutorials\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/\",\"name\":\"Guide to CSS Viewport Units: vw, vh, vmin, vmax - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-viewport-units-vw-vh-wmin-vmax\\\/fullscreen-background.gif\",\"datePublished\":\"2017-06-12T15:01:04+00:00\",\"dateModified\":\"2018-04-09T08:51:15+00:00\",\"description\":\"Viewport-percentage lengths, or viewport units as they are more frequently referred to, are responsive CSS units that allow you to define dimensions as a\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-viewport-units-vw-vh-wmin-vmax\\\/fullscreen-background.gif\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-viewport-units-vw-vh-wmin-vmax\\\/fullscreen-background.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-viewport-units-vw-vh-wmin-vmax\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Guide to CSS Viewport Units: vw, vh, vmin, vmax\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/a601053a0ab457901e00cdc83bd5359e\",\"name\":\"Anna Monus\",\"description\":\"Anna is Technical Editor and Writer for Hongkiat.com. She mainly covers front-end frameworks, web standards, accessibility, WordPress development, and UX design.\",\"sameAs\":[\"https:\\\/\\\/www.annalytic.com\\\/\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/anna_monus\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Guide to CSS Viewport Units: vw, vh, vmin, vmax - Hongkiat","description":"Viewport-percentage lengths, or viewport units as they are more frequently referred to, are responsive CSS units that allow you to define dimensions as a","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/","og_locale":"en_US","og_type":"article","og_title":"Guide to CSS Viewport Units: vw, vh, vmin, vmax","og_description":"Viewport-percentage lengths, or viewport units as they are more frequently referred to, are responsive CSS units that allow you to define dimensions as a","og_url":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2017-06-12T15:01:04+00:00","article_modified_time":"2018-04-09T08:51:15+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/fullscreen-background.gif","type":"","width":"","height":""}],"author":"Anna Monus","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Anna Monus","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/"},"author":{"name":"Anna Monus","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/a601053a0ab457901e00cdc83bd5359e"},"headline":"Guide to CSS Viewport Units: vw, vh, vmin, vmax","datePublished":"2017-06-12T15:01:04+00:00","dateModified":"2018-04-09T08:51:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/"},"wordCount":812,"commentCount":3,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/fullscreen-background.gif","keywords":["CSS","CSS Tutorials"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/","url":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/","name":"Guide to CSS Viewport Units: vw, vh, vmin, vmax - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/fullscreen-background.gif","datePublished":"2017-06-12T15:01:04+00:00","dateModified":"2018-04-09T08:51:15+00:00","description":"Viewport-percentage lengths, or viewport units as they are more frequently referred to, are responsive CSS units that allow you to define dimensions as a","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/fullscreen-background.gif","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-viewport-units-vw-vh-wmin-vmax\/fullscreen-background.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/css-viewport-units-vw-vh-wmin-vmax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Guide to CSS Viewport Units: vw, vh, vmin, vmax"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/a601053a0ab457901e00cdc83bd5359e","name":"Anna Monus","description":"Anna is Technical Editor and Writer for Hongkiat.com. She mainly covers front-end frameworks, web standards, accessibility, WordPress development, and UX design.","sameAs":["https:\/\/www.annalytic.com\/"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/anna_monus\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-7QE","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/30172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=30172"}],"version-history":[{"count":2,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/30172\/revisions"}],"predecessor-version":[{"id":42204,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/30172\/revisions\/42204"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=30172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=30172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=30172"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=30172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}