ArticleslgStudy

science

Media queries

Media queries is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Media queries rather than just read about it. In short: Media queries is a feature of CSS 3 allowing content rendering to adapt to different conditions such as screen resolution (e.g. mobile and desktop screen size). It became a W3C recommended standard in June 2012, and is a cornerstone technology of responsive web design (RWD).

Key takeaways

  • Media queries belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Media queries to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Media queries from memory before moving on to harder problems.

Reference excerpt

Media queries is a feature of CSS 3 allowing content rendering to adapt to different conditions such as screen resolution (e.g. mobile and desktop screen size). It became a W3C recommended standard in June 2012, and is a cornerstone technology of responsive web design (RWD).

History Media queries were first sketched in Håkon Wium Lie's initial CSS proposal in 1994, but they did not become part of CSS 1. The HTML4 Recommendation from 1997 shows an example of how media queries could be added in the future. In 2000, W3C started work on media queries and also on another scheme for supporting various devices: CC/PP. The two address the same problem, but CC/PP is server-centric, while media queries are browser-centric. The first public working draft for media queries was published in 2001. Media Queries Level 3, published as a Candidate Recommendation on 27 July 2010, became a W3C Recommendation on 19 June 2012. Proposed corrections were published on 5 April 2022. Media Queries Level 4, published as a Working Draft on 9 May 2017, were a W3C Candidate Recommendation Draft as of 25 December 2021.

Usage A media query consists of a media type and one or more expressions, involving media features, which resolve to either true or false. The result of the query is true if the media type specified in the media query matches the type of device the document is being displayed on and all expressions in the media query are true. When a media query is true, the corresponding style sheet or style rules are applied, following the normal cascading rules. Media queries use the @media CSS "at-rule".

Examples The following are examples of CSS media queries:

Media types A media type can be declared in the head of an HTML document using the "media" attribute inside of a <link> element. The value of the "media" attribute specifies on what device the linked document will be displayed. Media types can also be declared within XML processing instructions, the @import at-rule, and the @media at-rule. CSS 2 defines the following as media types:

all (suitable for all devices) braille embossed handheld print projection screen speech tty TV The media type "all" can also be used to indicate that a style sheet applies to all media types.

Media features The following table contains the media features listed in the latest W3C recommendation for media queries, dated 6 June 2007.

References

External links W3C – Media Queries recommendation 19 June 2012 W3C – CSS specs > Media Queries "CSS Media Queries". CodeSpot. Archived from the original on 29 October 2019.

Worked examples

Example 1 — a first encounter with Media queries

Start with the simplest possible case. Write down what Media queries claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Media queries before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Media queries ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Media queries

In research
Media queries appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Media queries in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Media queries is common in secondary-school and first-year university syllabi. It links to neighbouring topics Adaptive web design, Cascading Style Sheets, Responsive web design, so understanding it makes those chapters shorter.
In everyday life
Look for Media queries outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Media queries” →

How to study Media queries in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Media queries means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Media queries out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Media queries in simple terms?

Media queries is a feature of CSS 3 allowing content rendering to adapt to different conditions such as screen resolution (e.g. mobile and desktop screen size). It became a W3C recommended standard in June 2012, and is a cornerstone technology of responsive web design (RWD).

Why does Media queries matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Media queries?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Media queries.

Tags

  • Adaptive web design
  • Cascading Style Sheets
  • Responsive web design

Keep exploring