Skip to article frontmatterSkip to article content
tools = require('../js/tools'); tools.init()
Loading...

purpose

as per this article on w3schools :

The media rule is used in media queries to apply different styles for different media types/devices

Media queries can be used to check many things, such as:

  • width and height of the viewport

  • width and height of the device

  • orientation (is the tablet/phone in landscape or portrait mode?)

  • resolution

  • printing, ...

example - width

Loading...

common pitfall

example - print

Loading...

another way to use media rules is from the <head> tag

<link rel="stylesheet"
    <!-- NOTE the new media attribute here -->
    media="screen and (min-width: 900px)"
    href="widescreen.css">
<link rel="stylesheet"
    media="screen and (max-width: 600px)"
    href="smallscreen.css">

devel tools and multi-device

see also

practice

  1. open the example below in a separate window

  1. write an HTML document and related CSS that mimicks it

Loading...