Introduction to Media Queries
CSS media query attributes in HTML website webpage is a fundamental concept for a responsive website design element. CSS media query features help web developers to apply multiple concepts in user custom webpage website according to user specific electronic devices and gadgets, such as different device screen size, screen pixel resolution, device orientation, and other web important elements. Media queries help you to ensure that the website user interface, user experience you design previews and works properly on all devices available today ranging from portable and non-portable desktops, laptops, notebooks, smartphones.

What are Media Queries in CSS?
CSS media queries in HTML website webpage are responsive custom website web layout design method or process. Where you can develop a complete responsive website webpage using media queries. Where they help you in custom responsive web development according to the available portable and non-portable electronic devices. Where they help any web developers to create responsive website layouts compatible with different small to large electronic device screen sizes and screen orientations through media query.
Basic syntax of media query in CSS.
In the fundamental syntax of CSS media query in HTML website webpage, after the @media rule, the type of media and media query condition attributes are displayed.
@media media-type and (condition) {
/* type CSS rules here */
}
Media Query Example.
@media screen and (max-width: 700px) {
body {
background-color: aqua;
}
}
CSS media query types.
In HTML website webpage, you mainly get these media query options in CSS media query common media types.
CSS media query attributes types.
- Media query all – This applies to all electronic device gadgets of CSS media query in the current HTML website webpage.
- Media query screen – This applies CSS media query in the existing HTML website webpage to screen compatible devices, such as desktop computers, tablet computers, smartphones, cell phones, etc.
- Media query print – This applies CSS media query in the existing HTML website webpage to print the document or display the print preview of the document.
- Media query speech – This applies CSS media query in the existing HTML website webpage to read the electronic document online with a screen reader.
CSS media query features.
CSS media query media features in the existing HTML website webpage help you target the specific need of a particular responsive electronic device. These are the main features in general CSS media query media features.
CSS media query attributes features.
- Media query width – These properties help configure the width of the CSS media query viewport in the existing HTML website webpage, such as device maximum-width, minimum-width, etc.
- Media query height – These properties help to configure the height of the CSS media query viewport in the existing HTML website webpage, e.g., maximum-height, minimum-height of the device.
- Media query orientation – These properties help to configure the orientation of the CSS media query device in the existing HTML website webpage, e.g., device screen portrait, landscape screen orientation.
- Media query resolution – These properties help to configure the resolution of the CSS media query device in the existing HTML website webpage, e.g., minimum-screen resolution of the device screen, to maximum-screen resolution.
CSS media query in HTML website webpage is an important element written to create a responsive design. Without it, it is not possible to create a responsive website layout and design.
Here we are given an example, which shows the use of media query to create a responsive webpage layout.
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Css Responsive Web Layout With Media Queries </title>
<style>
body {
font-family: monotype corsiva;
margin: 4;
padding: 30px;
background-color: white;
}
header {
background-color: aqua;
font-size: 1.7em;
color: black;
padding: 20px 0;
text-align: center;
}
/* use default style for large screen */
main {
font-size: 1.9rem;
}
/* use style for smaller screen */
@media screen and (max-width: 700px) {
header {
background-color: blue;
}
main {
font-size: 2rem; /* display font size for small screen */
padding: 20px; /* it add padding between main element */
}
}
</style>
</head>
<body>
<header>
<h1>You can See Responsive Web Layout With Css Media Query</h1>
</header>
<main>
<p><center>A Simple Media Query Paragraph Text</center></p>
</main>
</body>
</html>
Css Media Query Files.
body {
font-family: monotype corsiva;
margin: 4;
padding: 30px;
background-color: white;
}
header {
background-color: aqua;
font-size: 1.7em;
color: black;
padding: 20px 0;
text-align: center;
}
/* use default style for large screen */
main {
font-size: 1.9rem;
}
/* use style for smaller screen */
@media screen and (max-width: 700px) {
header {
background-color: blue;
}
main {
font-size: 2rem; /* display font size for small screen */
padding: 20px; /* it adds padding between main element */
}
}
CSS media query in HTML website webpage conclusion.
CSS media queries in HTML website webpages are an important factor in creating responsive website webpage designs compatible with multiple portable and non-portable devices and screen size orientations. By using CSS media queries in HTML website webpages in an effective order, you can develop a complete user compatible website user interface, user experience, responsive website layout. You can develop custom user defined media query webpages in any way as per your web development needs!