{"id":13249,"date":"2014-07-25T12:17:54","date_gmt":"2014-07-25T12:17:54","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=13249"},"modified":"2019-10-23T14:25:29","modified_gmt":"2019-10-23T14:25:29","slug":"responsive-web-design-and-media-queries","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/","title":{"rendered":"Responsive Web Design and Media Queries"},"content":{"rendered":"<p>The term Responsive Web Design which is most commonly known as RWD refers to the aim of designing web pages in such a way that web pages can be viewed with the maximum ease along with great user experience over a wide range of devices which may include small screen sized mobile, tablet or large sized computer monitors. Responsive Web Design is considered as the key feature for better user experience on portable devices.<\/p>\n<p>So let\u2019s get into responsive web design and see how it actually works &#8211;<\/p>\n<p>To design a responsive web page we need basic knowledge of Media Query.<\/p>\n<p>Media Query usually instructs any of the modern browser to use CSS according to the width of device whether it\u2019s portable device or computer monitor. Whenever we design responsive web page we always add different css rules for different screen sizes using the media queries.<\/p>\n<p>Media Query includes two quite new terms which are min-width and max-width the term min-width refers to minimum size of screen required to allow CSS on device, similarly max-width refers to maximum size upto which CSS can be allowed on device.<\/p>\n<p>Here is how a media rule looks like-<\/p>\n<p>&nbsp;<\/p>\n<pre>@media only screen and (min-width: 320px)\n  {\n   \/*Generic CSS Syntax*\/\n }\n\n@media only screen and (max-width: 320px)\n   {\n   \/*Generic CSS Syntax*\/\n }\n<\/pre>\n<p>Apart from media rules we also have to add html meta tag. Why do we use meta tag? We use<\/p>\n<ul>\n<li>&#8220;width=device-width&#8221; as meta content to make sure that the width of browser adapts the width of device.<\/li>\n<li>&#8220;initial-scale=1&#8221; as meta content to set the default zoom level to 100%.<\/li>\n<li>&#8220;maximum-scale=1&#8221; as meta content because if device switches from portrait to landscape view it\u2019s layout may distort.<\/li>\n<li>&#8220;user-scalable=no&#8221; as meta content if we don\u2019t want user to zoom the web page.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Let\u2019s get into code to understand media rules which are considered as basic aspect of responsive web page design in more appropriate manner, Lets begin with a very basic HTML layout. Whenever we code css for responsive web page we must use percent as a unit for widths. Keeping this in mind let\u2019s code the css for html layout.<\/p>\n<p>Here is the <code>html<\/code> and <code>css<\/code> structure of layout &#8211;<\/p>\n<p><iframe style=\"border:solid 1px #f2f2f2\" width=\"100%\" height=\"500\" src=\"\/\/jsfiddle.net\/nitishkmrk\/taqxLdw3\/1\/embedded\/result,html,css\/\" allowpaymentrequest=\"\" allowfullscreen=\"allowfullscreen\" frameborder=\"0\" loading=\"lazy\"><\/iframe><\/p>\n<p>You can easily see in the above html code we have created a normal layout which consists header, banner, 4 category blocks and footer. We have used three css media rules to make the layout responsive which are as follows &#8211;<\/p>\n<ul>\n<li>@media screen and (min-width:1170px){&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; }This media query applies to all of the screen sizes which are larger than 1170px<\/li>\n<li>@media screen and (max-width:1170px){&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; }This media query applies to all of the screen sizes which are smaller than 1170px<\/li>\n<li>@media screen and (max-width:768px){&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; }This media query applies to all of the screen sizes which are smaller than 768px<\/li>\n<\/ul>\n<p>We have already defined a media rule for max screen size 768px so the media rule for 1170px will work for screen sizes larger than 768px and not for screen sizes lesser than 768px.<\/p>\n<p>We have just removed the float property from the category blocks to stack the layout and to display category blocks one below another.<\/p>\n<p>Now we have got a clear picture of how media queries actually works for different screen sizes and how we can code different css for different screen sizes using media rules.<\/p>\n<p>After media query we must discuss a little about the \u201cTwitter Bootstrap\u201d which is the considered as the best Responsive CSS Framework for framing responsive web pages. Bootstrap is also based on the same basic concept of media rules but at the very advanced level.<\/p>\n<p>Bootstrap is a grid based designing framework which have twelve grids by default and have fixed breakpoints for different screen sizes to stack the layout for a better user experience by re-sizing and re-adjusting the grids. All the information about how bootstrap actually works can be collected from Bootstrap docs, However we gonna discuss about bootstrap soon till then let\u2019s try to make a web more better place via responsive web page for better UI and UX.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The term Responsive Web Design which is most commonly known as RWD refers to the aim of designing web pages in such a way that web pages can be viewed with the maximum ease along with great user experience over a wide range of devices which may include small screen sized mobile, tablet or large <a href=\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1202],"tags":[],"class_list":["post-13249","post","type-post","status-publish","format-standard","hentry","category-design-trends"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Responsive Web Design and Media Queries - Webkul Blog<\/title>\n<meta name=\"description\" content=\"Understanding the responsive web design and media queries for designing the responsive web pages with better UI and UX.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Responsive Web Design and Media Queries - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Understanding the responsive web design and media queries for designing the responsive web pages with better UI and UX.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-25T12:17:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-23T14:25:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nitish Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nitish Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/\"},\"author\":{\"name\":\"Nitish Kumar\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/fee4a399dfbd8dfc6570efdf7295c9aa\"},\"headline\":\"Responsive Web Design and Media Queries\",\"datePublished\":\"2014-07-25T12:17:54+00:00\",\"dateModified\":\"2019-10-23T14:25:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/\"},\"wordCount\":668,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"articleSection\":[\"Design Trends\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/\",\"url\":\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/\",\"name\":\"Responsive Web Design and Media Queries - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2014-07-25T12:17:54+00:00\",\"dateModified\":\"2019-10-23T14:25:29+00:00\",\"description\":\"Understanding the responsive web design and media queries for designing the responsive web pages with better UI and UX.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Responsive Web Design and Media Queries\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/fee4a399dfbd8dfc6570efdf7295c9aa\",\"name\":\"Nitish Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a3100c52e659f7064fa37a0619aaea352fbe8a258f0ea0155361075df617e95b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a3100c52e659f7064fa37a0619aaea352fbe8a258f0ea0155361075df617e95b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Nitish Kumar\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/nitish\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Responsive Web Design and Media Queries - Webkul Blog","description":"Understanding the responsive web design and media queries for designing the responsive web pages with better UI and UX.","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:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/","og_locale":"en_US","og_type":"article","og_title":"Responsive Web Design and Media Queries - Webkul Blog","og_description":"Understanding the responsive web design and media queries for designing the responsive web pages with better UI and UX.","og_url":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2014-07-25T12:17:54+00:00","article_modified_time":"2019-10-23T14:25:29+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Nitish Kumar","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Nitish Kumar","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/"},"author":{"name":"Nitish Kumar","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/fee4a399dfbd8dfc6570efdf7295c9aa"},"headline":"Responsive Web Design and Media Queries","datePublished":"2014-07-25T12:17:54+00:00","dateModified":"2019-10-23T14:25:29+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/"},"wordCount":668,"commentCount":1,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"articleSection":["Design Trends"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/","url":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/","name":"Responsive Web Design and Media Queries - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2014-07-25T12:17:54+00:00","dateModified":"2019-10-23T14:25:29+00:00","description":"Understanding the responsive web design and media queries for designing the responsive web pages with better UI and UX.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/responsive-web-design-and-media-queries\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Responsive Web Design and Media Queries"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/fee4a399dfbd8dfc6570efdf7295c9aa","name":"Nitish Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a3100c52e659f7064fa37a0619aaea352fbe8a258f0ea0155361075df617e95b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a3100c52e659f7064fa37a0619aaea352fbe8a258f0ea0155361075df617e95b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Nitish Kumar"},"url":"https:\/\/webkul.com\/blog\/author\/nitish\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/13249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=13249"}],"version-history":[{"count":28,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/13249\/revisions"}],"predecessor-version":[{"id":200732,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/13249\/revisions\/200732"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=13249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=13249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=13249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}