Home > Web Front-end > CSS Tutorial > How Can I Implement CSS Media Queries in IE8?

How Can I Implement CSS Media Queries in IE8?

Mary-Kate Olsen
Release: 2024-12-24 16:18:10
Original
682 people have browsed it

How Can I Implement CSS Media Queries in IE8?

IE8 and CSS Media Queries: Troubleshooting and Alternatives

Question:

IE8 appears to lack support for the following media query:

@import url("desktop.css") screen and (min-width: 768px);
Copy after login

If this is true, what alternative syntax can be used?

Answer:

IE8 indeed does not support CSS media queries. As a workaround, you can use the following code:

@import url("desktop.css") screen; 
@import url("ipad.css") only screen and (device-width:768px);
Copy after login

However, this solution has its limitations. It does not support all media query features available in modern browsers.

Alternative Solution:

For a more complete solution that emulates media queries in IE8, consider using the css3-mediaqueries-js script. This script emulates media queries, but it has some constraints:

  • It does not work on imported stylesheets.
  • It ignores the media attribute on and