Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS print vs screen stylesheets

Status
Not open for further replies.

cl8855

Programmer
Nov 28, 2000
47
US
If I use print and screen stylesheets as shown here:
Code:
<link rel="STYLESHEET" type="text/css" media="screen" href="test.css">
<link rel="stylesheet" type="text/css" media="print" href="print.css">

Then shouldn't I be able to have the same tag in each stylesheet, for example p.bold, where each does a different thing if it is print vs. screen?

what I am seeing is my print settings are working only for tags that I do not have in my test.css

any ideas let me know,
 
If you have 2 stylesheets loaded into the same page, with the same properties, the "second" stylesheet will be the one to take precedence over the other.

So, as per your question, "print.css" will be the one the browser chooses, because it is coded after "test.css"

&quot;Hey...Where are all the chicks?&quot; -- unknown
 
What you are expecting should be the case. Do you have the site online somewhere where we can test it? Do you experience this kind of behaviour in different browsers?
 
Maybe you should change the stylesheet to print.css only when the user goes to print a page. After which you can set it back to test.css. I don't think the browser cares about the media attribute as far as loading goes.
 
xWasted:
That is not what appears to happen, because the text is formatted as per test.css, while "unique" tags from the print.css also work.

Vrag:
Unfortunately it is only for internal use (not online).
Luckily we have a standardized IE6 browser so I don't have to worry about multiple.

Supra:
Ya, I will try loading the sheet based on whether it was selected as print or not.


Anyone else have ideas? Is there any way to force a page setup to landscape by default?
 
What I meant with different browser was if you can test the behaviour and see if it is a browser specific issue. IE is not the most capable browser when it comes to css although we are using the exact same technique on our company website and it works. Could you make a strip down of the code and paste it here. You can omit the confidential information, we just need to see the problem in action.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top