Forum Moderators: not2easy
I got him to send some screenshots, and it looks as if IE5 is applying the CSS rules contained in @media print {...} on the screen. Eg my CSS file says (simplified version):
@media print {
a:link { color:black; text-decoration:none; }
}
and, sure enough, links appear on his screen in black with no underline.
Have I understood the problem correctly? What is the workaround for this?
Anyone know anything about this?
[edited by: Nick_W at 5:23 pm (utc) on Oct. 22, 2003]
[edit reason] corrected link 404 [/edit]
In fact, the bug does solve my problem, provided I follow the instructions literally. They call for placing a comment ('/* */') immediately after the selector. Thus, in my example,
@media print {
a:link/* */ { color:black; text-decoration:none; }
}
will cause Internet Explorer 5 to ignore the rule.
Where I initially went wrong was to allow a space to intrude between the selector and the comment. Do that and it causes IE5 to process the rule correctly.
I am interested in why no one volunteered an answer. Am I the only person to be affected by IE5's mishandling of "@media print"? Does no one else use CSS to format printed web pages differently from what appears on the screen, or do other people use a different technique? Should I have approached the problem in a different way? I'd be interested in comments.
I'm not working with sites that require a lot of printing right now, and the clients involved don't want to pay extra to have everything print well -- just a few special sections where we make downloadable files (pdfs and rtfs) for printing.
That said, I've been following your one-sided conversation with interest. You've taught me something (don't include a space) and you've reminded me of other things I'm sure I will need sooner or later. Much appreciated.
It's not that there's no need for printable web pages. There exist a large number of web sites - including WebmasterWorld - that offer "printer-friendly" pages. This option is, in general, unnecessary for sites that use CSS, since CSS2 can be used to format pages differently for print and for screen. Thus, on the printed page, you can hide "back to the top of the page" links and the suchlike, you can change the fonts to pts and the colour to black, alter the way headings are presented, etc (you can think of your own examples).
With a page formatted for printing using CSS, therefore, the user does not need to download an extra page to print the information, and the developer (or the server, if the pages are dymnamic) does not need to create two separate pages containing the same information. (The need for one page rather than two is, incidentally, a point Brett Tabke should take into account when calculating whether or not CSS adds to downoad time [webmasterworld.com]). This technique even works with Internet Explorer versions 5.5 and 6, so the "design for IE" people are going to be kept happy.
It is also possible, for Mozilla and Opera users, to offer large print formats. (A couple of months ago I suggested that CSS could be used to solve the problems of people with poor vison, and Nick_W responded that he thought this would be difficult. It isn't - although it involves some effort if you're converting an existing site rather the building the facility into a site from scratch.)
Of course, as long as business insists on using yesterday's technologies, then none of this is really going to get used, which is a pity.