Problem:
Within an inherited project, there's a need to specifically target Internet Explorer for styling without modifying HTML, using CSS exclusively.
Solution:
Internet Explorer 9 and Lower:
<!--\[if IE]--\> <link rel="stylesheet" type="text/css" href="all-ie-only.css" /> <!\[endif]--\>
Internet Explorer 10 and 11:
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { /* IE10+ CSS styles go here */ }
Microsoft Edge 12:
@supports (-ms-accelerator:true) { /* IE Edge 12+ CSS styles go here */ }
Inline Rule for IE8 and Below:
/* For IE css hack */ margin-top: 10px /* apply to all ie from 8 and below */ *margin-top:10px; /* apply to ie 7 and below */ _margin-top:10px; /* apply to ie 6 and below */
Note: For inline stylesheets, consider using media queries and conditional comments for versions below IE9.
The above is the detailed content of How Can I Style Only Internet Explorer (All Versions) Using CSS Alone?. For more information, please follow other related articles on the PHP Chinese website!