Tips for building HTML documents that are intended to be converted to PDF.
The media attribute and media queries
First, it’s really important to tell the browser to use your styles for print media! If you’re wondering “why aren’t my styles being picked up at all?!” - make sure that you’re using the media attribute or a media query.
There are a few ways you can do this. When linking to an external stylesheet, you can set the media attribute to all. This instructs the browser to use these styles for all media types, including print:
You can also set the media attribute on inline <style> tags:
If you’d like to specify different styles for screen and print media, one option is to load two stylesheets: