Blog Detail

Home Blog Detail

How to write Media Query?

Blog Img

A media query in CSS is a technique used to apply different styles based on the device’s screen size, resolution, orientation, or other properties. It helps in making websites responsive, ensuring they look good on all devices (mobile, tablet, desktop).

@media (condition) {
  /* CSS rules */
}
@media(max-width:767px)
{
 body{
  background-color: red;
 }
}
@media(min-width:768px and max-width:991px)
{
 background-color: green;
}
@media(min-width:992px and max-width:1199px)
{
 body{
  background-color: blue;
 }
}
@media(min-width:1200px)
{
 body{
   background-color: yellow;
 }
}
@media (orientation: landscape) {
  body {
    background-color: lightblue;
  }
}

© 2025Think4u. All Rights Reserved.