How to see the print media CSS in Firebug?

CssPrintingFirebugPrint Css

Css Problem Overview


Firebug is an excellent tool to to show a screen media CSS for some HTML element, but is there a way to look at the print media CSS too? Or is there any other tool to see the print media CSS?

Css Solutions


Solution 1 - Css

What about Web Developer Toolbar?
https://addons.mozilla.org/en-US/firefox/addon/60
when installed go to CSS -> Display CSS by media type -> Print

Solution 2 - Css

Newer Firefox

  1. Open devtools with F12.
  2. Go to Inspector tab.
  3. Open Rules subtab.
  4. There will be print media button.

enter image description here

Old firefox

Firefox does not need firebug now.

  1. Run developer toolbar by pressing Shift+F2
  2. Type media emulate print

Type media reset in order to return to standard view.

Solution 3 - Css

I would have never expected this to work, but it does. Install -both- the 1.5 beta of Firebug and Web Developer. When you choose the print css from Web Developer, the tools in Firebug suddenly work on the new print version of the page. So far I haven't found any problems with running both at the same time.

Solution 4 - Css

Use the Web Developer plug in. Then you can choose from the CSS menu which media you want the page to display as.

Solution 5 - Css

You might want to take a look at the webdeveloper toolbar - it allows you to select what CSS you want to see. In conjunction with firebug, it should be possible to see the print media CSS.

Solution 6 - Css

In Firefox (and some other browsers), you can see a static display of the print stylesheet by using Print Preview. It's nowhere near as useful as the web developer toolbar, but it can also help you understand what is going to be printed.

Solution 7 - Css

Actually, be aware that you might see @media print CSS when you don't expect it.

Like SO uses:

[..]@media print{#sidebar,#nav,[..],div.vote{display:none;}}[..]

...and hence one might expect the CSS panel in Firebug to somehow show:

@media print {
#sidebar, #nav, [..], div.vote {
display: none;
}
}

But instead it shows the CSS as if the @media print is actually active, like:

#sidebar, #nav, [..], div.vote {
display: none;
}

http://i.stack.imgur.com/KSgKr.png"><img src="http://i.stack.imgur.com/KSgKr.png" width="200">

(See also the related issue report: CSS Panel does not have @media UI.)

Solution 8 - Css

Edit 2 After reading Arjan's answer, I realize that this solution does not address correctly sites using (or abusing) the @media print CSS. (See example below.) But I think this solution still holds valid as a "non-perfect-quick-and-dirty-trick", above all for code that you have written and that you know beforehand that it doesn't have this.


With Firebug, you also can edit the <link rel="stylesheet" type="text/css" ...> and <style> tags to your convenience.

For example, you can switch an original

<link rel="stylesheet" type="text/css" media="print">

to

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

and the browser will apply it. You'll also have to deactivate the screen-only ones.

Of course, this is only useful if you only want to quick-check a few pages with very few stylesheet links, but at least, you do not need to install any additional plugins.


Edit 1 This trick suggests me using javascript to automate this...

(Disclaimer: I'll use JQuery for simplicity. I'm not a Javascript expert.)

// Save all stylesheet links
allStylesheets   = $('link[rel="stylesheet"], style');
// Save the print-stylesheet links
printStylesheets = $('link[media*="print"], link[media*="all"], style[media*="print"], style[media*="all"]');

// Set all stylesheet medias to something 'exotic'
if (null != allStylesheets) {
    allStylesheets.attr("media", "aural");
}
// Switch the print-stylesheet medias to 'screen'
if (null != printStylesheets) {
    printStylesheets.attr("media", "screen");
}

Note that the default media is "screen" (w3.org - media attribute). This could be used in a button to show a page preview. The only drawback is that you have to reload the page to restore the original view.

As pointed out above, this solution does not work with html code like this, because the styling inside the @media print won't be applied by the browser:

<html>
    <head>
        <title>Hello world</title>
        <style type="text/css" media="all">
            @media print { h1 { color: red; }}
        </style>
    </head>
    <body>
        <h1>Hello world</h1>
    </body>
</html>

Solution 9 - Css

Web developer toolbar has one big drawback for CSS debugging though: every time you refresh the page it reverts to the screen stylesheet.

What I tend to do these days is temporarily switch the media of the print stylesheet to screen while I'm developing, and then switch it back before going live.

Solution 10 - Css

Firefox 68 added a button to "Toggle print media simulation for the page" to the Rules View of the Page Inspector (Bug 1534984):

Screenshot of Firefox Page Inspector with

There's a video of how to use the button in "View @media rules for Print" section of the "Examine and edit CSS" page.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJanko MivšekView Question on Stackoverflow
Solution 1 - CssMads MobækView Answer on Stackoverflow
Solution 2 - CssAlexander CView Answer on Stackoverflow
Solution 3 - CssclintmView Answer on Stackoverflow
Solution 4 - CsstvanfossonView Answer on Stackoverflow
Solution 5 - CsstomjenView Answer on Stackoverflow
Solution 6 - CssalexView Answer on Stackoverflow
Solution 7 - CssArjanView Answer on Stackoverflow
Solution 8 - CssAlbertoView Answer on Stackoverflow
Solution 9 - CsswheresrhysView Answer on Stackoverflow
Solution 10 - CssKevinoidView Answer on Stackoverflow