Media queries serve as a simple if
statement in the realm of other programming languages.
screen
: The screen
designation is utilized to establish guidelines specifically for computer screens, tablets, or smartphones. Other media types include projection
or print
.
max-width
: sets the maximum width for the screen (or media) where the CSS rules apply. All rules under this category cater to screens equal to or smaller than the specified value.
min-width
: establishes the minimum width necessary for the screen (or media) targeted by the CSS rules. All rules here pertain to screens larger than the indicated value.
Illustration #1 (utilizing min-width
):
@media screen and (min-width: 456px) { ... }
The CSS rules within this query are tailored exclusively for computer screens, tablets, or smartphones with a minimum width of 456 pixels.
Illustration #2 (employing max-width
):
@media screen and (max-width: 456px) { ... }
The CSS rules contained in this section are only applicable to computer screens, tablets, or smartphones with a maximum width of 456 pixels.
CSS3 Media Queries: Check out the official documentation on CSS3 media queries here.