Media Query
Media Query
is used to apply styles to a web page depending on the screen sizes of different devices like smartphones, tablets, and PCs, to display the optimal layout and design.
Basic Structure
Media Query begins with @media
followed by the conditions.
The styles for the matching condition are enclosed within curly braces { }
.
Example:
CSS
/* Styles for screens less than 600px wide */ @media screen and (max-width: 600px) { body { background-color: lightblue; /* Set the background color to light blue */ } }
In this example, when the screen width is less than 600px, the background color of the body
is set to lightblue
.
Mission
0 / 1
Media Query is used to adjust the style of a web page according to the screen size.
True
False
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help