theorise
theorise

Reputation: 7425

Browser controlled text for print stylesheet

Is there an easy way to overwrite all text/header styles to let the browser handle the text formatting in the print stylesheet?

Edit: I have lots of styles such as

#id .class .class #id .class p{}

Upvotes: 0

Views: 182

Answers (3)

theorise
theorise

Reputation: 7425

I have learnt that any CSS formatting created in a stylesheet specified as screen does means that the printing page will be unformatted.

In my example, I can't touch the HTML and the CSS media has not been specified, so the problem remains, but you should always make sure you set this to avoid problems in other medias.

Set the CSS globally (including print)

<link href="style.css" rel="stylesheet" type="text/css">

Set the CSS just for screen (excludes any media, including print format)

<link href="style.css" rel="stylesheet" type="text/css" media="screen">

Upvotes: 0

Brian Scott
Brian Scott

Reputation: 9361

Make sure that any styles you have applied to the text / header which you do not want applied during "print" mode are specified as;

@media screen {
  .headerStyle { color: green; }
}

They will then be ignored during the @print screen mode.

Upvotes: 1

Quentin
Quentin

Reputation: 943510

No. You can only cascade downwards, and you can't refer to other styles. Limit the CSS you have to the media types you want in the first place.

Upvotes: 0

Related Questions