How can CSS be used to create different layouts for online and print versions of a webpage in PHP?
To create different layouts for online and print versions of a webpage in PHP, you can use CSS media queries to target specific styles for each version. By defining different styles for screen and print media types, you can control how the webpage appears on a screen and when printed. This allows you to optimize the layout and design for each medium.
<!DOCTYPE html>
<html>
<head>
<style>
/* Styles for online version */
@media screen {
body {
background-color: lightblue;
}
}
/* Styles for print version */
@media print {
body {
background-color: white;
}
}
</style>
</head>
<body>
<h1>This is a webpage</h1>
<p>Content goes here</p>
</body>
</html>
Related Questions
- What potential issues can arise when using reserved words like "date" and "text" in a PostgreSQL database with PHP?
- What are the best practices for displaying text when a menu is expanded in a PHP application?
- What are the best practices for handling user input in SQL queries to prevent SQL injection vulnerabilities?