I have the following html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<span class="print">Print only</span> - <span class="noprint">Display Only</span>
</body>
</html>
main.css
@import url("screen.css") screen;
@import url("print.css") print;
screen.css
.print
{
display:none;
}
print.css
.noprint
{
display: none;
}
span.print
{
display: inline !important;
}
div.print
{
display: block !important;
}
When I view the page in the browser then as expected the “Display Only” span displays and the “Print Only” one doesn’t.
However, when I go to print preview, or print the page, it doesn’t appear to be using print.css?
I’m using IE8, which I thought supported @import?
Apparently IE doesn’t support the “print” on the end of the @import line.
Use this instead:
then add the “@media” rule into the stylesheet itself.