Media Queries

  • By
  • August 1, 2022
  • Web Development

Media Queries

We can write CSS specifically for certain situations If a frequenter has a web cyber surfer that supports media queries( IE9 and over). For illustration, we can descry that a frequenter has a small device like a smartphone and give them a specific layout. We can add specific CSS for small defenses or large defenses( inside our slinging style sheets). By putting our CSS media queries at the bottom of our style sheets, we can simply overwrite any style rules we have declared before in our CSS.


For Free, Demo classes Call: 8237077325
Registration Link: Click Here!


Media Queries in a Nutshell:- A media query is an expression that evaluates to either True or False.  The media query syntax allows the creation of rules. A media query consists of a test, followed by as multitudinous CSS rules as we want, with the rule block enclosed in a set of braces. However, the cyber surfer simply ignores the rule block and moves on, If the test condition is false. 

The media queries in CSS3 can be used to check for a particular condition analogous to the range and height( of the cyber surfer window), device range and height, exposure, or resolution. Media queries allow for subtle or drastic changes in the appearance of a website controlled entirely within the point’s CSS. If our media queries come last in our CSS, they will overwrite former CSS rules, as long as they resolve to TRUE.  Media queries have coiled braces. You Have Multiple Options open if you attend our Front End Development Course in Pune

Media Query Rule illustration 

@media screen and( min- range 800px)


Media Query Parts:- A media query consists of 3 corridors the Media Type, an Expression, and the Style Rules contained within the media query itself. 

  1. The Media Type( illustration screen) allows us to declare what type of media the rules should be applied to. In four ways you can declare all, print, screen, and speech. 
  2. Expressions( illustration( min- range 800px) allow you to further target bias predicated on specific conditions you pass to the media query. Expressions test media features, which describe different features of a device, analogous as range and height. 
  3. CSS Style Rules can be listed inside the media query’s coiled braces. Colored Pencils, Pencil Boxes, and Recesses Let’s think of Each CSS Style Rule as a varicolored pencil since we constantly use CSS Style Rules to add color to a website. 

Let’s think of CSS3 Media Queries as a box that holds the varicolored pencils. We can have a bunch of pencils in a box and several boxes in a hole. Let’s think of the CSS style sheet that holds everything as the hole. Of course, there may be some pencils in the hole that are not inside the pencil boxes. So not every CSS Rule has to be in the CSS Media Queries, only the bones that are targeting specific cyber surfer extensions, etc. It also is a CSS Style Rule illustration( the varicolored pencil) h3{ color red;} We can add color to our website with the CSS Style Rule over. Also, we’re making all our h3 captions red. Also, we can limit that color to small defenses, if we like, by begirding that style rule in a CSS Media Query. It also is the CSS3 Media Query( the pencil box) with a CSS Style Rule outside( the varicolored pencil). 


For Free, Demo classes Call: 8237077325
Registration Link: Click Here!


screen and( min- range 800px){ h3{ color red;} 

Calling Media Queries There are two ways to call a media query using an external style sheet, or writing directly inside a style sheet. The syntax of a media query is the same no matter if you use it inside a link element, after an @ import instruction, or inside a CSS style sheet. You can use media queries to include them inside your single style sheet. You can also use a media query to add a breakpoint at 768px and target a computer screen. 

Only screen and( maximum- range 768px){} Breakpoints 

We can add breakpoints so that certain corridors of our design will bear differently on each side of the breakpoint. Common breakpoints include the 

320px( for smartphones), 768px( for tablets), and 1024px( for desktop spectators). Complex Expressions You can compose complex media queries using logical motorists, including not, and, and only. Multiple media queries can also be combined in a comma-separated list; if any of the media queries in the list is true, the entire media statement returns true. ( This is original to an or motorist.) AND( and keyword) The AND motorist is the bone you’ll presumably use the most. It’s used for combining multiple media features together into a single media query. All the conditions which are specified must be satisfied before the styling rules will take effect. It also is a media query illustration containing the AND motorist min- width800px) and( maximum- width1200px){}
You can Start Learning CSS with Front End Development Training in Pune where we teach all the concepts in depth with practical questions.


For Free, Demo classes Call: 8237077325
Registration Link: Click Here!


NOTE:- CSS Style Rules are not included in the below illustration( so it actually does nothing). But they are shown in the bones below.) Media Query samples with CSS Rules outdoors( stressed in red) 

( min- range 768px){ body{ fringe 0 machine; fringe-top 20px; only screen and( min- range 601px) and

( maximum- range 1200px){ body{ background yellow;} h3{ color red;} 

In the last illustration, the two CSS rules inside the body of the media query will only be applied if the cyber surfer window range is at or between 601 pixels and 1200 pixels. Media and CSS styles also include “curly braces,” so you will see CSS  “curly braces ” nested inside media query “ curly braces. ” 

In summary, introductory CSS3 media queries are actually simple to learn and easy to add to slinging style sheets to target different web biases or screen sizes. They just take a little practice.



Sarika Ganesh Kore
Call the Trainer and Book your free demo Class  Call now!!!

| SevenMentor Pvt Ltd.

© Copyright 2021 | Sevenmentor Pvt Ltd.

Submit Comment

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