I have a very simple html page with a table element.
The document is styled with css. When I print the page it looks like there are no stylesheets at all. Wrong font, everything is wrong.
What's the problem here? Do I have to create a special css only for printing? In my case it would be the same.. Is that really necessary?
Make sure that you add the rel attribute to the link tag When you add an external CSS file to your HTML document, you need to add the rel="stylesheet" attribute to the <link> tag to make it work. If you omit the rel attribute from the <link> tag then the style won't be applied to the page.
You can use CSS to change the appearance of your web page when it's printed on a paper. You can specify one font for the screen version and another for the print version.
Developer Tools. The DevTools ( F12 or Cmd/Ctrl + Shift + I ) can emulate print styles, although page breaks won't be shown. In Chrome, open the Developer Tools and select More Tools, then Rendering from the three-dot icon menu at the top right. Change the Emulate CSS Media to print at the bottom of that panel.
We can add a page break tag with style "page-break-after: always" at the point where we want to introduce the pagebreak in the html page.
Without the link to the page, I can only offer little advice.
Make sure the link to the stylesheet in the header is correct. And it should look something like this:
<link rel="stylesheet" type="text/css" href="/link/to/.css" media="all">
I just noticed that you mentioned print
. The all
media type will work across web and print. However, if you wanted to explicitly state another stylesheet for print
than replace the all
with print
.
If your stylesheet link has media="screen"
, then it will be ignored by print. In that case you can create a separate print stylesheet with media="print"
or just change your existing style sheet to media="all"
.
The media
attribute is used to determine the stylesheet purpose. You need to make sure that it is set to all
(for all purposes) or print
(only used when printing).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With