Having printed matter use an exclusive stylesheet
Currently I have my stylesheets as such:
<link rel="stylesheet" media="print" href="css/print.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/style.css"/>
Is there a way to force style.css to be only on a monit开发者_运维技巧or, and force print to only be on printed matter? I'm trying to make a printer-friendly page and it's taking forever to override the mass of rules in style.css.
Use media="screen"
on the main stylesheet so styles are only applied on a monitor screen:
<link rel="stylesheet" media="print" type="text/css" href="css/print.css" />
<link rel="stylesheet" media="screen" type="text/css" href="css/style.css" />
If you don't specify a media
attribute, the stylesheet takes a default of media="all"
, which means styles are applied everywhere.
Read more about media types here (HTML spec) and here (CSS spec).
精彩评论