{"id":2087,"date":"2016-11-13T14:09:11","date_gmt":"2016-11-13T14:09:11","guid":{"rendered":"http:\/\/cssreset.com\/?p=2087"},"modified":"2016-11-13T14:09:11","modified_gmt":"2016-11-13T14:09:11","slug":"css-and-metadata-the-html-viewport-tag","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/css-and-metadata-the-html-viewport-tag\/","title":{"rendered":"CSS and Metadata: The HTML Viewport Tag"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>Creating a responsive and mobile friendly site happens mostly in the CSS stylesheets with media queries and responsive rules, however there is one absolutely vital line of HTML that must be included in your site&#8217;s header file if you want your pages to be responsive, and that&#8217;s the meta viewport tag.<\/p>\n<p>The viewport is the area of a page that&#8217;s visible to the viewer. As you probably know, the viewport on a laptop or a desktop monitor is significantly larger than that of a mobile phone or tablet, which is the whole reason that responsive design is necessary at all. The goal of responsive and mobile friendly designs is to make sure that a page looks just as good on a mobile device as it does on a desktop. So to create a truly responsive design, we need to be able to control the viewport. That&#8217;s where the meta viewport tag comes in:<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\r\n\r\n\t\t<div class=\"toolbar\">\r\n\r\n\t\t<div class=\"view-different-container\">\r\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\r\n\t\t\t\t\t<\/div>\r\n\r\n\t\t<div class=\"language-name\">HTML<\/div>\r\n\r\n\t\t\r\n\t\t<br clear=\"both\">\r\n\r\n\t<\/div>\r\n\t\r\n\t<div class=\"code\">\r\n\t\t<ol class=\"html4strict\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #ddbb00\">&amp;lt;<\/span>meta\u00a0name=&quot;viewport&quot;\u00a0content=&quot;width=device-width, initial-scale=1.0&quot;<span style=\"color: #ddbb00\">&amp;gt;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\r\n\r\n<\/div>\r\n\n<p>That one simple line above will make it so that the width of your user&#8217;s device = the width of your page. The one line of HTML combined with your media queries will allow for your pages to become completely mobile friendly and responsive.<\/p>\n<p>To see the viewport meta tag in action, take a look at the two images below. The first is a screenshot of what CSS Reset looks like on a mobile device without the viewport tag, and the second is screenshot of how it looks with the viewport tag. The difference is pretty clear&#8230;so make sure you don&#8217;t forget to add the viewport tag when you&#8217;re creating your next responsive page.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-2090 aligncenter\" alt=\"Screen Shot 2016-11-13 at 9.08.17 AM\" src=\"https:\/\/cssdeck.com\/blog\/\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-13-at-9.08.17-AM.png\" width=\"374\" height=\"640\" srcset=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-13-at-9.08.17-AM.png 374w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-13-at-9.08.17-AM-175x300.png 175w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-13-at-9.08.17-AM-180x308.png 180w\" sizes=\"(max-width: 374px) 100vw, 374px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-2089 aligncenter\" alt=\"Screen Shot 2016-11-13 at 9.08.38 AM\" src=\"https:\/\/cssdeck.com\/blog\/\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-13-at-9.08.38-AM.png\" width=\"366\" height=\"638\" srcset=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-13-at-9.08.38-AM.png 366w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-13-at-9.08.38-AM-172x300.png 172w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2016\/11\/Screen-Shot-2016-11-13-at-9.08.38-AM-180x313.png 180w\" sizes=\"(max-width: 366px) 100vw, 366px\" \/><\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>&nbsp;<\/p>\n<p>Creating a responsive and mobile friendly site happens mostly in the CSS stylesheets with media queries and responsive rules, however there is one absolutely vital line of HTML that must be included in your site&#8217;s header file if you want [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/css-and-metadata-the-html-viewport-tag\/\" title=\"Click to read 'CSS and Metadata: The HTML Viewport Tag'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":2089,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2087"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=2087"}],"version-history":[{"count":2,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2087\/revisions"}],"predecessor-version":[{"id":2091,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2087\/revisions\/2091"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media\/2089"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=2087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=2087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=2087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}