Media Query CSS For All Devices With Example


Media Query CSS For All Devices With Example

In this tutorial, I will discuss the media query CSS for all devices. Actually, media query CSS or CSS3 comes from CSS2. In CSS2 the @media rule, all the styles were based on different types of devices like computer screens, printers and television, and so on.

On the other hand, media queries css3 inherits the rules of CSS2 media types and checks for the capability of the device instead of the type of device.

We can obtain the below features using a media query.

  • width and height of the viewport
  • width and height of the device
  • orientation of the device whether the device is in landscape mode or portrait mode.
  • resolution of the device

Media queries are used to deliver predefined stylesheets according to the device such as desktops, laptops, tablets, and mobile phones automatically.

Also read, Overflow in CSS with Example

Supported browsers of media queries are as follows

  • Google Chrome
  • Microsoft Edge
  • Mozilla
  • Safari
  • Opera

Number of media types:-

  • all:- Used for all devices
  • print:- Used for printers
  • screen:- Used for computer screens, laptops, smartphones, etc.
  • speech:- Used for screenreaders that “read” the page out loud

Syntex of media query:-

@media not|only mediatype and (expressions) {
  CSS-Code;
}

A media query contains media type and one or more expressions that result in true or false.

The result of the query is true if the media type matches the type of the device where the document is displayed and all expressions in the media query are true. When the media query is true, the related style sheets are applied following the normal CSS properties.

Can I use a media query inside the style tag of the head section? YES

Let us take an example to see how media query works

HTML File:- (mediaquery.html)

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
  background-color: lightgreen;
}
@media screen and (min-width: 480px) {
  body {
    background-color: blue;
  }
}
</style>
</head>
<body>

<h1 style="color: white;">Resize the browser window to see how the color changes!</h1>
<p style="color: white;">The background color will change according to the mediatype .i.e. screen and the viewport is more than 480px .</p>

</body>
</html>

In this example, you will see that the background color of the HTML web page will change according to the size of the device. If the device size is more than 480px then the background will be blue color and if the device size is less than 480px then the background will be green.
Output for device size greater than 480px

Media Query CSS For All Devices With Example

Output for device size less than 480px

Media Query CSS For All Devices With Example

Conclusion:- I hope this tutorial will help you to understand the overview of media query CSS for all devices. If there is any doubt then please leave a comment below


Leave a Comment

RATU311

RATU311

THOR311

parlay

CERI188

HOKI311

RATU311

RATU311

judi bola online

Mix Parlay

THOR311

Ceri188

Thor311 Game Online

Thor311 Aplikasi

LINK CERI188

RATU311 NONTON BOLA

RATU311

HOKI311 Link Alternatif

CERI188 Link RTP LIVE

THOR311

THOR311

Thor311 Live Casino

CERI188

akses VIP THOR311

THOR311

link daftar THOR311

THOR311

situs thor311

THOR311 LOGIN

THOR311

THOR311

THOR311

RATU311

RATU311

HOKI311 Link SABUNG AYAM RESMI

HOKI311 Link QRIS EWALLET

RATU311

LINK CERI188

parlay

HOKI311 Link RTP Gacor

THOR311

RATU311

THOR311

THOR311

HOKI311 Link Apk Resmi

RATU311

KUPU178

RATU311

RATU311

RATU311

CERI188

CERI188 Situs Spaceman Terbaik 2026

KUPU178 Link Daftar

CERI188

CERI188

CERI188

CERI188

CERI188

HOKI311

THOR311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

CERI188 Live Casino

HOKI311 Lapak Arena Slot

RATU311 judi bola

CERI188 Live Casino

HOKI311 Link Spaceman Online

RATU311

HOKI311 Link Daftar Resmi

CERI188 Toto SGP Online

KUPU178

KUPU178

KUPU178

KUPU178

HOKI311 TEMBAK IKAN ONLINE

RATU311

CERI188 PANDUAN MAXWIN SLOT ONLINE

RATU311

RATU311

RATU311

KUPU178

HOKI311 Link Login Alternatif

HOKI311 Live Casino Online

HOKI311 Situs Slot Gacor

THOR311

THOR311

situs judi bola

THOR311

Ceri188 Game Online

CERI188

link login CERI188

THOR311

link login CERI188

CERI188

link login CERI188

link login CERI188

link daftar CERI188

THOR311

HOKI311

HOKI311

CERI188

CERI188

CERI188

parlay

THOR311

RATU311

RATU311

HOKI311

HOKI311

parlay

HOKI311

RATU311

THOR311

KUPU178

HOKI311

KUPU178

KUPU178

KUPU178

HOKI311

parlay

slot gacor

kupu178 link alternatif

kupu178 slot

kupu178 daftar

kupu178 login

link daftar kupu178

judi bola

HOKI311

RATU311

link alternatif RATU311

Link daftar RATU311

link login RATU311

RATU311

RATU311

RATU311

RATU311

KUPU178

KUPU178

KUPU178

THOR311

KUPU178

KUPU178

KUPU178

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

RATU311

THOR311

RATU311

KUPU178

KUPU178

HOKI311

THOR311

KUPU178

THOR311

THOR311

slot thailand

judi bola

THOR311

THOR311

KUPU178

THOR311

situs bola

THOR311

slot gacor

slot gacor

yakuza303

slot gacor

unobet77

slot gacor

slot gacor

RATU311

parlay

parlay

slot gacor

mix parlay

judi bola

judi bola

mix parlay

parlay

judi bola

sv388

judi bola

judi bola

judi bola

parlay

THOR311