![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I do not want to load two style sheets for screen and print media. I'm having difficulty grasping the use of the @print statement, or its syntax. Would someone please provide a simple explanation. For example... If I have a style sheet specifying media="all," is the following correct syntax to center text for printing, but not for screen presentation? |
#3
| |||
| |||
|
|
Ed Jay wrote: I do not want to load two style sheets for screen and print media. I'm having difficulty grasping the use of the @print statement, or its syntax. Would someone please provide a simple explanation. For example... If I have a style sheet specifying media="all," is the following correct syntax to center text for printing, but not for screen presentation? Corrected syntax: @media print { .divClass1 { text-align: center; } } Thanks. I presume this will supercede a previous style for divClass1 in a |
#4
| |||
| |||
|
|
I do not want to load two style sheets for screen and print media. I'm having difficulty grasping the use of the @print statement, or its syntax. Would someone please provide a simple explanation. For example... If I have a style sheet specifying media="all," is the following correct syntax to center text for printing, but not for screen presentation? .divClass1 { text-align:left; } @print .divClass1 { text-align:center; } |
#5
| |||
| |||
|
|
Ed Jay wrote: I do not want to load two style sheets for screen and print media. I'm having difficulty grasping the use of the @print statement, or its syntax. Would someone please provide a simple explanation. For example... If I have a style sheet specifying media="all," is the following correct syntax to center text for printing, but not for screen presentation? .divClass1 { text-align:left; } @print .divClass1 { text-align:center; } In CSS there is no such thing as @print. The correct form for what you're trying to do is @media print { .divClass1 { text-align: center; } } |
#6
| |||
| |||
|
|
Ed Jay wrote: I do not want to load two style sheets for screen and print media. Mind listing the reason for that? I find that a separate print style sheet greatly reduces maintenance. For one, you don't have to pore through hundreds of lines of screen styles looking for each print style. The few you probably need would be easily accessible in one small place. Download time would be next to nothing. |
#7
| |||
| |||
|
|
I find that a separate print style sheet greatly reduces maintenance. |
|
For one, you don't have to pore through hundreds of lines of screen styles looking for each print style. |
|
Download time would be next to nothing. |

#8
| |||
| |||
|
|
Beauregard T. Shagnasty wrote: I find that a separate print style sheet greatly reduces maintenance. Not necessarily. Depends on how the CSS is organized, I think. For one, you don't have to pore through hundreds of lines of screen styles looking for each print style. The problem with that is some styles I often want for both screen and print. That means either duplicating them in the print stylesheet, or loading 2 stylesheets. Too much trouble for me to keep that stuff straight. Besides, I never intermix screen only and print rules. I prefer to use 1 stylesheet and section it off by media type. I've been doing it this way for so long I know exactly where to look for certain rules. @media screen, projection, print { global rules like heading fonts, floating images, etc. } @media screen, projection { screen only rules like navigation, background images, etc. } @media print { print only rules, like display:none for navigation, etc. } I suppose you could stick handheld in there, too, but I don't bother. If they get info sans CSS, that's fine with me. Download time would be next to nothing. It is. IIRC, at least some browsers retrieve all stylesheets whether they need them or not, then apply the applicable rules depending on what the user requests. It's fewer server calls putting them into 1 external stylesheet. If your CSS is huge, however, then you should rethink a few things. KISS comes to mind. ![]() |
#9
| |||
| |||
|
|
Corrected syntax: @media print { .divClass1 { text-align: center; } } Thanks. I presume this will supercede a previous style for divClass1 in a media=all sheet, as in the example I gave? Only if it comes after the stylesheet for divClass1. |
|
I also presume that I can include multiple declarations within the @print {..}? You mean "@media print { ... }"? |
#10
| |||
| |||
|
|
On 07/01/08 11:57 am, Ed Jay wrote: Corrected syntax: @media print { .divClass1 { text-align: center; } } Thanks. I presume this will supercede a previous style for divClass1 in a media=all sheet, as in the example I gave? Only if it comes after the stylesheet for divClass1. I also presume that I can include multiple declarations within the @print {..}? You mean "@media print { ... }"? Yes. It is like any other style ruleset, just restricted to print media. The normal ruleset has an implied "@media all { ... }". |
![]() |
| Thread Tools | |
| Display Modes | |
| |