CSS Media Query
Responsive
CSS
- Between two screen sizes
<style>
@media screen and (min-width: 992px) and (max-width: 1200px) {
body { background-color: red; }
}
</style>- Desktop only
<style>
@media screen and (min-width: 992px) {
body { background-color: red; }
}
</style>- Tablet & below only
<style>
@media screen and (max-width: 991px) {
body { background-color: red; }
}
</style>- Non-touch devices only
<style>
@media (pointer: fine) {
body { background-color: red; }
}
</style>- Prefers reduced motion
<style>
@media screen and (prefers-reduced-motion: reduce) {
body { background-color: red; }
}
</style>- Prefers contrast
<style>
@media (prefers-contrast: more) {
body { background-color: red; }
}
</style>- Prefers dark mode
<style>
@media screen and (prefers-color-scheme: dark) {
body { background-color: red; }
}
</style>Preview Links
Custom JS
Enable custom code in preview or view on published site.
Enable custom code?
Last Updated: Dec 3, 2025
- Between two screen sizes
<style>
@media screen and (min-width: 992px) and (max-width: 1200px) {
body { background-color: red; }
}
</style>- Desktop only
<style>
@media screen and (min-width: 992px) {
body { background-color: red; }
}
</style>- Tablet & below only
<style>
@media screen and (max-width: 991px) {
body { background-color: red; }
}
</style>- Non-touch devices only
<style>
@media (pointer: fine) {
body { background-color: red; }
}
</style>- Prefers reduced motion
<style>
@media screen and (prefers-reduced-motion: reduce) {
body { background-color: red; }
}
</style>- Prefers contrast
<style>
@media (prefers-contrast: more) {
body { background-color: red; }
}
</style>- Prefers dark mode
<style>
@media screen and (prefers-color-scheme: dark) {
body { background-color: red; }
}
</style>