How can CSS media queries be effectively utilized to adjust content display based on screen size in PHP?
To adjust content display based on screen size in PHP, CSS media queries can be effectively utilized. By using media queries in the CSS file, different styles can be applied to elements based on the screen size. This allows for a responsive design that adjusts the layout and appearance of the website to fit various screen sizes.
<!DOCTYPE html>
<html>
<head>
<style>
/* Default styles */
.content {
width: 100%;
background-color: lightblue;
}
/* Media query for screens smaller than 600px */
@media screen and (max-width: 600px) {
.content {
background-color: lightcoral;
}
}
</style>
</head>
<body>
<div class="content">
<p>This is the content that will adjust based on screen size.</p>
</div>
</body>
</html>