Combining Multiple Media Queries
Use and, or, and not operators to combine media features into complex queries.
The and Operator
The and keyword requires all conditions to be true simultaneously. Useful for targeting specific device sizes and types together.
@media screen and (min-width: 768px) {
/* Screens 768px and up */
}Range with and
Combining min-width and max-width with and targets a specific viewport width range (tablet-only styles):
@media (min-width: 768px) and (max-width: 1023px) {
/* Tablet range only */
.layout {
grid-template-columns: 1fr 1fr;
}
}All lessons in this course
- Syntax and Common Breakpoints
- Width Height and Orientation Queries
- Prefers-Color-Scheme and Prefers-Reduced-Motion
- Combining Multiple Media Queries