If we look at the CSS3 specifications , there is a section in which it deals with this subject. They call it Processing of conditional group rules
.
According to the example provided by the specification (own translation):
For example, with this set of nested rules:
@media print { // rule (1)
/* hide navigation controls when printing */
#navigation { display: none }
@media (max-width: 12cm) { // rule (2)
/* keep notes in flow when printing to narrow pages */
.note { float: none }
}
}
The condition of the marked rule (1) is true for printed media, and the condition of the marked rule (2) is true when the width of the print area (which for printed media is the page box) is lower ao equal to 12cm. Therefore, the rule '#navigation {display: none}' applies whenever this style sheet is applied to printed media, and the rule '.note {float: none}' is applied only when the stylesheet is applied to printed media and the width of the frame of the page is less than or equal to 12 centimeters.
IMPORTANT NOTE: Remember that the order of media queries is important and, therefore, they have to go from less to more restrictive in descending order (the order of CSS). That is, if you have a max-width
of 600px as a restriction and another of 400px you should first go to the 600px.