{"id":14838,"date":"2020-04-17T20:46:50","date_gmt":"2020-04-18T03:46:50","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=14838"},"modified":"2023-12-01T02:41:32","modified_gmt":"2023-12-01T10:41:32","slug":"css-media-queries","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/css-media-queries\/","title":{"rendered":"CSS Media Queries"},"content":{"rendered":"\n<p>Designing websites that are compatible across different devices is an important step in ensuring that a website is accessible to as many different users as possible.<br><\/p>\n\n\n\n<p>That\u2019s where media queries come in. CSS media queries allow you to apply a CSS rule only when the browser matches a rule that you have defined. So, you could define a rule that applies only if a user is viewing a web page on a smartphone.<br><\/p>\n\n\n\n<p>This tutorial will discuss, with examples, the basics of responsive web design, how media queries work, and how to design your own CSS media queries. By the end of reading this tutorial, you\u2019ll be an expert at designing media queries in CSS.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Responsive Web Design and Media Queries<\/h2>\n\n\n\n<p>Responsive web design refers to a set of practices where a developer optimizes a style sheet on a site so that the site can be rendered correctly on a wide range of different devices and screen sizes.<br><\/p>\n\n\n\n<p>The reason that responsive web design is so important is that the output device a viewer uses to look at a web page\u2014and its browser window and screen size\u2014will impact how the web page loads. If a website is not designed with different devices and screen sizes in mind, then some users may struggle to view all the content that is presented on the website.<br><\/p>\n\n\n\n<p>While responsive web design encompasses a wide range of practices\u2014from using flexbox to relative styles\u2014media queries are a crucial part of any website that is designed with web responsiveness in mind.<br><\/p>\n\n\n\n<p>Media queries allow you to adjust how styles appear on a web page depending on the type of device used, the orientation of a device, and the viewport size.<br><\/p>\n\n\n\n<p>By using media queries, you can make elements appear differently on your website based on the different screens and devices through which a user is viewing your site.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Media Query Syntax<\/h2>\n\n\n\n<p>To declare a media query in CSS, you need to use the <code>@media<\/code> rule. This rule allows you to execute a block of CSS properties only if a certain condition evaluates to true.<br><\/p>\n\n\n\n<p>Here is the basic syntax for a CSS media query:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>@media media-type and (media-rule) {\n\t\/\/ CSS styles\n}<\/pre><\/div>\n\n\n\n<p>Here are the main components of this media query:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>@media<\/strong> instructs the browser to create a media query.<\/li>\n\n\n\n<li><strong>media-type<\/strong> is the type of media the code will be used for (i.e. screen or print).<\/li>\n\n\n\n<li><strong>and<\/strong> is a logical operator that we need to use when specifying both a media type and a media rule.<\/li>\n\n\n\n<li><strong>media-rule<\/strong> is the statement that must evaluate to true in order for the CSS in the media query to execute.<\/li>\n\n\n\n<li><strong>CSS styles<\/strong> are the rules that will be applied to a web element if the media-rule evaluates to true.<\/li>\n<\/ul>\n\n\n\n<p>There are four media types that can be used with a media query. These are all, print, screen, and speech. By default, the value <code>all<\/code> is used, and multiple media types can be specified by separating each type using a comma.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CSS Media Rules<\/h2>\n\n\n\n<p>There are a few rule types that can be applied to a media query. Let\u2019s break down each of these individually.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Width and Height<\/h3>\n\n\n\n<p>The main rule types used with CSS media rules are device width and height. These rules allow us to apply styles to a web element depending on the size of the viewport container. The term <code>viewport container<\/code> refers to the area of a web page visible to a user.<br><\/p>\n\n\n\n<p>The width and height rules are used to apply a style if the viewport is exactly equal to a certain size. So, if you wanted to change the text color of all &lt;p&gt; tags on a web page to blue if the viewport is 500px tall, you could do so using this rule:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>@media screen and (width: 500px) {\n\tp {\n\t\tcolor: blue;\n\t}\n}<\/pre><\/div>\n\n\n\n<p>This rule sets the text color of all &lt;p&gt; tags to <code>blue<\/code> if the width of the viewport is exactly 500px.<br><\/p>\n\n\n\n<p>In most cases, though, you will want to apply a media query using ranges. So, for example, you may want to change the font size of a web page if the viewport size is equal to or greater than 500px. That\u2019s where the min-width and min-height styles come in.<br><\/p>\n\n\n\n<p>If we wanted to change the text color of all &lt;p&gt; elements to blue if the viewport width is equal to greater than 500px, we could use the following rule:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>@media screen and (min-width: 500px) {\n\tp {\n\t\tcolor: blue;\n\t}\n}<\/pre><\/div>\n\n\n\n<p>This rule sets the text color of all &lt;p&gt; elements to blue, but only if the viewport width is equal to or greater than 500px. The way this media query works is the condition min-width: 500px is evaluated, which checks whether the viewport width is equal to or greater than 500px. If this condition evaluates to true, the rules in our <code>p<\/code> style are applied to the web page.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Orientation<\/h3>\n\n\n\n<p>In addition, media queries can be used to apply styles to a web page depending on the orientation of a device.<br><\/p>\n\n\n\n<p>Suppose we want to set the text size of all h2 elements to 20px if the user is viewing our web page in landscape mode. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>@media (orientation: landscape) {\n\th2 {\n\t\tfont-size: 20px;\n\t}\n}<\/pre><\/div>\n\n\n\n<p>This rule checks if the user is viewing the web page in landscape mode, and sets the font size of all &lt;h2&gt; elements to 20px if that condition evaluates to true.<br><\/p>\n\n\n\n<p>By default, desktops use landscape orientation.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CSS Media Query Examples<\/h2>\n\n\n\n<p>Let\u2019s walk through two example media queries to illustrate how you can write your own media queries in CSS.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Media Query Example: Hide Element<\/h3>\n\n\n\n<p>Suppose we are designing a website and we want to have a box appear that shows <code>This site is in beta<\/code>. on all mobile devices. This box should appear only on mobile devices because we are still testing our mobile experience.<br><\/p>\n\n\n\n<p>We could create this box using the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;html&gt;\n&lt;p class=\"betaBox\"&gt;This site is in beta.&lt;\/p&gt;\n&lt;html&gt;\n  \n&lt;style&gt;\n.betaBox {\n\tbackground-color: orange;\n\tpadding: 10px;\n}\n&lt;style&gt;\n@media screen and (max-width: 600px) {\n\t.betaBox {\n\t\tdisplay: none;\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"653\" height=\"39\" src=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/beta.png\" alt=\"\" class=\"wp-image-14843\" srcset=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/beta.png 653w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/beta-640x39.png 640w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/beta-385x23.png 385w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/beta-20x1.png 20w\" sizes=\"auto, (max-width: 653px) 100vw, 653px\" \/><\/figure>\n\n\n\n<p>Let\u2019s break down our code. In our HTML file, we have defined a &lt;p&gt; tag which includes the text <code>This site is in beta<\/code>. The class assigned to the &lt;p&gt; tag is <code>betaBox<\/code>.<br><\/p>\n\n\n\n<p>In our CSS file, we specified two styles. The .betaBox style sets the background color of any element with the class name <code>betaBox<\/code> to orange and creates a 10px padding space between the contents of the element and its borders.<br><\/p>\n\n\n\n<p>The next rule uses a media query. In our media query, max-width: 600px tells our browser that the style rule should only be applied if the viewport is narrower than 600px. So, if a user views our site on a mobile device, this style will be invoked.<br><\/p>\n\n\n\n<p>If our media query is executed, the display: none rule is applied to every element with the class name <code>.betaBox<\/code>.&nbsp;<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Multiple Media Queries Example: Font Size<\/h3>\n\n\n\n<p>In our previous example, we only specified one media query. However, you are able to specify multiple media queries in a CSS file, which means that you can apply certain styles to an element on a web page depending on whether one of the multiple conditions are met.<br><\/p>\n\n\n\n<p>Suppose we are designing a website and we want the font size of our &lt;h1&gt; headers to change depending on the screen size. Here are the rules we want to apply to our site:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the width of the screen is equal to or less than 480px, the font size of our headers should be 16px.<\/li>\n\n\n\n<li>If the width of the screen is equal to 481px and equal to or less than 600px, the header font size should be 20px.<\/li>\n\n\n\n<li>If the width of the screen is equal to or greater than 601px, the header font size should be 24px.<\/li>\n<\/ul>\n\n\n\n<p>We could use the following three media queries to change the size of the fonts on our web page depending on the size of the user\u2019s screen:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;html&gt;\n&lt;h1&gt;This is an example header.&lt;\/h1&gt;\n&lt;html&gt;\n  \n&lt;style&gt;\n@media screen and (min-width: 480px) {\n\th1 {\n\t\tfont-size: 16px;\n\t}\n}\n@media screen and (min-width: 481px) and (max-width: 600px) {\n\th1 {\n\t\tfont-size: 20px;\n\t}\n}\n@media screen and (min-width: 601px) {\n\th1 {\n\t\tfont-size: 24px;\n\t}\n}\n&lt;style&gt;<\/pre><\/div>\n\n\n\n<p><em>Click the&nbsp;<\/em><img loading=\"lazy\" decoding=\"async\" width=\"24\" height=\"24\" class=\"wp-image-13930\" style=\"width: 24px;\" src=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/iconfinder_play-circle-outline_326584.png\" alt=\"Image of the &quot;Run Code&quot; Button, a triangle inside a circle\" srcset=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/iconfinder_play-circle-outline_326584.png 24w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/iconfinder_play-circle-outline_326584-20x20.png 20w\" sizes=\"auto, (max-width: 24px) 100vw, 24px\" \/> <em>button in the code editor above to see the output of our HTML\/CSS code.<\/em><\/p>\n\n\n\n<p>Let\u2019s break down how our code works. In our HTML file, we defined an example header using a &lt;h1&gt; tag which shows the text <code>This is an example header<\/code>.<\/p>\n\n\n\n<p>Then, in our CSS file, we defined three media queries.<br><\/p>\n\n\n\n<p>The first media query checks if the size of the browser viewport is equal to or less than 480px (using max-width: 480px), and sets the font size of all &lt;h1&gt; elements to 16px if this statement evaluates to true.<\/p>\n\n\n\n<p>The second media query checks if the size of the viewport is equal to or greater than 481px (using min-width: 481px) and equal to or less than 600px (using max-width: 600px). If this evaluates to true, the font size for all &lt;h1&gt; elements is set to 20px.<br><\/p>\n\n\n\n<p>The third media query checks if the size of the viewport is greater than 601px (using min-width: 601px). If this rule evaluates to true, the font size of all &lt;h1&gt; elements is changed to 24px.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Media Query Breakpoints<\/h2>\n\n\n\n<p>Breakpoints are used to set the points where a website will apply a media query.&nbsp;<br><\/p>\n\n\n\n<p>When you\u2019re designing a media query, you may ask yourself the question: what sizes should I use to set my media queries? This is a reasonable question, because when you are just starting with responsive web design you may find it difficult to figure out the sizes of the devices on which your website should render.<br><\/p>\n\n\n\n<p>There are lists on the internet that target specific screen sizes, which can be useful in setting the breakpoints for your media queries. However, due to the wide range of devices that are out there\u2014which all have their own screen sizes and specifications\u2014these lists usually do not cover all the main points.<br><\/p>\n\n\n\n<p>The best way to choose when a media query should trigger is to look through your website for any places where elements become squashed or trimmed. So, if you see an element that is not fully visible on a mobile device, you know that you may need to add a breakpoint.<br><\/p>\n\n\n\n<p>Then, once you have identified these points, you can write custom media rules. For example, you may realize that a &lt;div&gt; tag does not render correctly on devices whose width is less than 500px. In that case, you\u2019ll want to write a media query to design custom styles for this resolution.<br><\/p>\n\n\n\n<p>However, to get you started, here is a list of breakpoints which can help you target the main devices which may be used to visit your website:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Most phones: @media screen and (max-width: 600px) {}<\/li>\n\n\n\n<li>Portrait tablets and large phones: @media screen and (min-width: 600px) {}<\/li>\n\n\n\n<li>Landscape tablets: @media screen and (min-width: 768px) {}<\/li>\n\n\n\n<li>Laptops and desktop machines: @media screen (min-width: 992px) {}<\/li>\n\n\n\n<li>Large laptops and desktop machines: @media screen (min-width: 1200px) {}<\/li>\n<\/ul>\n\n\n\n<p>These rules should help you get started in determining the breakpoints for your media queries, but you may end up making a few changes to suit the particular needs of your website.<\/p>\n\n\n\n<iframe loading=\"lazy\" frameborder=\"0\" width=\"100%\" height=\"400px\" src=\"https:\/\/repl.it\/@careerkarma\/Media-Queries?lite=true\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Media queries are used in CSS to add responsive designs to a web page. Media queries allow you to apply a specific style when a condition or set of conditions is met. For example, a media query could be used to change the font size of a web page when the width of the web page is greater than 750px.<br><\/p>\n\n\n\n<p>This tutorial discussed, with reference to examples, the basics of responsive web design, how media queries work, and how you can write a media query. Now you\u2019re ready to start working with media queries in CSS like a professional web designer.<\/p>\n","protected":false},"excerpt":{"rendered":"Designing websites that are compatible across different devices is an important step in ensuring that a website is accessible to as many different users as possible. That\u2019s where media queries come in. CSS media queries allow you to apply a CSS rule only when the browser matches a rule that you have defined. So, you&hellip;","protected":false},"author":240,"featured_media":14839,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17287],"tags":[],"class_list":{"0":"post-14838","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-css"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"CSS","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>CSS Media Queries: The Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"CSS media queries are used to create responsive websites. On Career Karma, learn how to use media queries in CSS.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/css-media-queries\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS Media Queries\" \/>\n<meta property=\"og:description\" content=\"CSS media queries are used to create responsive websites. On Career Karma, learn how to use media queries in CSS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/css-media-queries\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-18T03:46:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:41:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"CSS Media Queries\",\"datePublished\":\"2020-04-18T03:46:50+00:00\",\"dateModified\":\"2023-12-01T10:41:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/\"},\"wordCount\":1916,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg\",\"articleSection\":[\"CSS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/css-media-queries\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/\",\"name\":\"CSS Media Queries: The Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg\",\"datePublished\":\"2020-04-18T03:46:50+00:00\",\"dateModified\":\"2023-12-01T10:41:32+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"CSS media queries are used to create responsive websites. On Career Karma, learn how to use media queries in CSS.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/css-media-queries\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/css-media-queries\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS\",\"item\":\"https:\/\/careerkarma.com\/blog\/css\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"CSS Media Queries\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"CSS Media Queries: The Complete Guide | Career Karma","description":"CSS media queries are used to create responsive websites. On Career Karma, learn how to use media queries in CSS.","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:\/\/careerkarma.com\/blog\/css-media-queries\/","og_locale":"en_US","og_type":"article","og_title":"CSS Media Queries","og_description":"CSS media queries are used to create responsive websites. On Career Karma, learn how to use media queries in CSS.","og_url":"https:\/\/careerkarma.com\/blog\/css-media-queries\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-04-18T03:46:50+00:00","article_modified_time":"2023-12-01T10:41:32+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"CSS Media Queries","datePublished":"2020-04-18T03:46:50+00:00","dateModified":"2023-12-01T10:41:32+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/"},"wordCount":1916,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg","articleSection":["CSS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/css-media-queries\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/","url":"https:\/\/careerkarma.com\/blog\/css-media-queries\/","name":"CSS Media Queries: The Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg","datePublished":"2020-04-18T03:46:50+00:00","dateModified":"2023-12-01T10:41:32+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"CSS media queries are used to create responsive websites. On Career Karma, learn how to use media queries in CSS.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/css-media-queries\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/04\/apple-computer-desk-electronics-374857-1.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/css-media-queries\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"CSS","item":"https:\/\/careerkarma.com\/blog\/css\/"},{"@type":"ListItem","position":3,"name":"CSS Media Queries"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/14838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=14838"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/14838\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/14839"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=14838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=14838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=14838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}