{"id":139655,"date":"2015-08-27T11:00:52","date_gmt":"2015-08-27T16:00:52","guid":{"rendered":"https:\/\/getflywheel.com\/?p=12537"},"modified":"2025-05-12T15:04:59","modified_gmt":"2025-05-12T20:04:59","slug":"how-to-style-your-website-for-print-with-css","status":"publish","type":"resource","link":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/","title":{"rendered":"How to Style your Website for Print with CSS"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">What does Print have to do with the Web?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Most of us live online, getting all of our information from the web. We\u2019re connected all day, every day, from many devices. You may have heard that print is dead when, in fact, that certainly isn\u2019t true! We may not print as frequently as we once did, but there are situations where viewing content on a device is just no substitute for having a hard printed copy to look at. Do you have valuable how-to content, redeemable coupons, directions, portfolio examples, or anything else that users would prefer to see in print? If so, setting up custom print rules on your website will certainly help shape the experience for your users.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/08\/print-styling-01-1024x539.jpg\" alt=\"Office printer on a desk next to a computer, coffee mug, and pen holder\" class=\"wp-image-12545\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">How to Design for Print<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">All the magic is contained within CSS by defining print-specific styles. You may find it helpful to create a separate <code>print.css<\/code> stylesheet so it is separate from all your other styles. Keep in mind that not all sites have a print style sheet; this is an additional feature and step in the development process. If no print styles are specified, the default styles are used for printing. We will be defining styles to make things more efficient for print, which will override any defaults.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The naming convention and specific styles will be unique to your own project\u2019s stylesheet, but these concepts will apply. After the basics are added, go through the default stylesheet of your website and look for any unique situations that need print styles to ensure the best printing experience.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Color and Layout Considerations<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Most people prefer to print in black and white due to the expense of colored ink. Also, there is a higher contrast when text is black and printed on white paper. You\u2019re probably familiar with media queries, as they are critical in modern, responsive web design. Media queries are also necessary for creating print styles.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is what will make text in the body black, and get rid of any background color for best printing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@media print {\nbody {\ncolor: #000;\nbackground: #fff;\n}\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Chances are, the text will print out in Times New Roman. There\u2019s nothing wrong with that, but what if you want to specify a different font? Just like you did in your default styles, this can be done in print as well. While we\u2019re at it, let\u2019s not forget the line height.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>body {\nfont: 13pt Tahoma, Geneva, sans-serif;\nline-height: 1.5;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Hiding Unnecessary Elements<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You\u2019ve probably been conditioned to keep the <code>display: none<\/code> to a minimum, but this is entirely okay for your print styles. By hiding some elements, you are giving your users a better way to print and keeping anything unnecessary from the hard copy. The goal is to allow them to effectively print out the most important content, not the exact web page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are page elements that are not necessary, like navigation, footer, sidebar, and background images, so this is where our <code>display: none<\/code> will come in handy.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@media print {\nnav, aside, footer {\ndisplay: none;\n}\n\nsection {\nbackground: none\n}\n\/* section had a patterned background in the default styling which is best removed in the print style *\/\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Articles are often printed, so it is great to have each article start on a separate page. It is much easier for the user to organize their printouts if key information is grouped together and not spread across multiple pages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By adding this to your print stylesheet, the articles will always start on a new page:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>article {\npage-break-before: always;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Keeping the unordered lists together on the same page is a great idea too:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ul {\npage-break-inside: avoid;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s take it a step further and do the same for headings, images, blockquotes, tables, and other list elements:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>h1, h2, h3, h4, h5, h6 {\npage-break-after:avoid;\npage-break-inside:avoid\n}\n\nimg {\npage-break-inside:avoid;\npage-break-after:avoid;\n}\n\nblockquote, table, pre {\npage-break-inside:avoid\n}\n\nul, ol, dl {\npage-break-before:avoid\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&amp;amp;amp;amp;amp;lt;\/pre&amp;amp;amp;amp;amp;gt;\n&amp;amp;amp;amp;amp;lt;img class=&amp;amp;amp;amp;quot;aligncenter wp-image-12547 size-full&amp;amp;amp;amp;quot; src=&amp;amp;amp;amp;quot;https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/08\/print-styling-03.jpg&amp;amp;amp;amp;quot; alt=&amp;amp;amp;amp;quot;print-styling-03&amp;amp;amp;amp;quot; width=&amp;amp;amp;amp;quot;1022&amp;amp;amp;amp;quot; height=&amp;amp;amp;amp;quot;480&amp;amp;amp;amp;quot; \/&amp;amp;amp;amp;amp;gt;\n&amp;amp;amp;amp;amp;lt;pre&amp;amp;amp;amp;amp;gt;\n&amp;amp;amp;amp;amp;lt;h3&amp;amp;amp;amp;amp;gt;Page margin measurements&amp;amp;amp;amp;amp;lt;\/h3&amp;amp;amp;amp;amp;gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We will be adding a width of 100% to the body and article and getting rid of any unnecessary margins or padding. That way we can strip out any unnecessary spacing.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>body, article {\nwidth: 100%;\nmargin: 0;\npadding: 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here is where the spacing can really be fine tuned for printouts. It\u2019s not too often that you see centimeters in web design, but it works great for the purpose of determining borders on the page. The <code>@page<\/code> rule is how we will target the spacing. This example will allow for 2cm around all the borders. This measurement can be customized to allow for more or less space. For instance, your users may want to take notes and allowing for a larger margin would be helpful.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@page {\nmargin: 2cm;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If pages are intended to be printed and put in a binder, keep in mind that there is the option to adjust the margins for every other page. Left page is for pages 1, 3, 5&#8230; and the right page is page 2, 4, 6&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@page :left {\nmargin: 1cm 3cm 1cm 2cm;\n}\n\n@page :right {\nmargin: 1cm 2cm 2cm 3cm;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">First-page customization comes in handy in certain instances. By using the <code>:first<\/code> page pseudo-class, the styling of the first printed page can be determined:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@page :first {\nmargin: 1cm 2cm;\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2015\/08\/print-styling-021-1024x348.jpg\" alt=\"a stack of blank white papers\" class=\"wp-image-12550\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Image and Intro Text Ideas<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">These may or may not apply to your site, but they are good to note nonetheless.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To prevent images from being cut off and bleeding over the edge of the printed page, adding a declaration of a max width will prevent this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>img {\nmax-width: 100% !important;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A nice welcome message is a great addition. Print content will be around for awhile, so it is always nice to include a friendly message or reminder.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>header:before {\ndisplay: block;\ncontent: &amp;amp;amp;amp;quot;Thank you for visiting my website at www.mysite.com.   Please check back for upcoming specials and new products.&amp;amp;amp;amp;quot;;\nmargin-bottom: 15px;\npadding: 5px 8px;\nfont-style: italic;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we\u2019ve covered some of the print consideration basics, it is easy to incorporate these ideas into your print stylesheet. Although print is not what we ultimately think of when we use the web, it is a great way to provide your users with the same great experience no matter how they are accessing content.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Stay Educated With WP Engine<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Would you like to learn more about WordPress, and the various ways you can use this platform to your company\u2019s advantage? Subscribe to our newsletter\u00a0and learn more about our\u00a0<a href=\"https:\/\/wpengine.com\/wordpress-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">managed hosting for WordPress<\/a>\u00a0and our\u00a0<a href=\"https:\/\/wpengine.com\/plans\/\" target=\"_blank\" rel=\"noreferrer noopener\">flexible hosting plans<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What does Print have to do with the Web? Most of us live online, getting all of our information from the web. We\u2019re connected all day, every day, from many devices. You may have heard that print is dead when, in fact, that certainly isn\u2019t true! We may not print as frequently as we once<span class=\"tile__ellipses\">&hellip;<\/span><span class=\"tile__ellipses--animated\"><\/span><\/p>\n","protected":false},"author":1,"featured_media":141012,"template":"","resource-topic":[1396,901],"resource-role":[1397,896],"resource-type":[916],"class_list":["post-139655","resource","type-resource","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Style your Website for Print with CSS | WP Engine<\/title>\n<meta name=\"description\" content=\"Setting up custom print rules on your website will help shape the experience for users. Here&#039;s how to style your site for print with CSS.\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Style your Website for Print with CSS | WP Engine\" \/>\n<meta property=\"og:description\" content=\"Setting up custom print rules on your website will help shape the experience for users. Here&#039;s how to style your site for print with CSS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Engine\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wpengine\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-12T20:04:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2015\/08\/print-header.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@wpengine\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/\",\"url\":\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/\",\"name\":\"How to Style your Website for Print with CSS | WP Engine\",\"isPartOf\":{\"@id\":\"https:\/\/wpengine.com\/case-studies\/#website\"},\"datePublished\":\"2015-08-27T16:00:52+00:00\",\"dateModified\":\"2025-05-12T20:04:59+00:00\",\"description\":\"Setting up custom print rules on your website will help shape the experience for users. Here's how to style your site for print with CSS.\",\"breadcrumb\":{\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wpengine.com\/case-studies\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resources\",\"item\":\"https:\/\/wpengine.com\/case-studies\/resources\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Style your Website for Print with CSS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#website\",\"url\":\"https:\/\/wpengine.com\/case-studies\/\",\"name\":\"WP Engine\",\"description\":\"Managed Hosting for WordPress\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wpengine.com\/case-studies\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/f5301455463371a10d1fc290e9ad0085\",\"name\":\"WP Engine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g\",\"caption\":\"WP Engine\"},\"sameAs\":[\"https:\/\/wpengine.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Style your Website for Print with CSS | WP Engine","description":"Setting up custom print rules on your website will help shape the experience for users. Here's how to style your site for print with CSS.","robots":{"index":"noindex","follow":"follow"},"og_locale":"en_US","og_type":"article","og_title":"How to Style your Website for Print with CSS | WP Engine","og_description":"Setting up custom print rules on your website will help shape the experience for users. Here's how to style your site for print with CSS.","og_url":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/","og_site_name":"WP Engine","article_publisher":"https:\/\/www.facebook.com\/wpengine","article_modified_time":"2025-05-12T20:04:59+00:00","og_image":[{"width":1100,"height":500,"url":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2015\/08\/print-header.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@wpengine","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/","url":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/","name":"How to Style your Website for Print with CSS | WP Engine","isPartOf":{"@id":"https:\/\/wpengine.com\/case-studies\/#website"},"datePublished":"2015-08-27T16:00:52+00:00","dateModified":"2025-05-12T20:04:59+00:00","description":"Setting up custom print rules on your website will help shape the experience for users. Here's how to style your site for print with CSS.","breadcrumb":{"@id":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wpengine.com\/case-studies\/resources\/how-to-style-your-website-for-print-with-css\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpengine.com\/case-studies\/"},{"@type":"ListItem","position":2,"name":"Resources","item":"https:\/\/wpengine.com\/case-studies\/resources\/"},{"@type":"ListItem","position":3,"name":"How to Style your Website for Print with CSS"}]},{"@type":"WebSite","@id":"https:\/\/wpengine.com\/case-studies\/#website","url":"https:\/\/wpengine.com\/case-studies\/","name":"WP Engine","description":"Managed Hosting for WordPress","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpengine.com\/case-studies\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/f5301455463371a10d1fc290e9ad0085","name":"WP Engine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g","caption":"WP Engine"},"sameAs":["https:\/\/wpengine.com"]}]}},"acf":[],"grid_image_url":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2015\/08\/print-grid.png","media-type":{"term_id":916,"name":"Article","slug":"article"},"role":"<strong>Roles:<\/strong> Designer, Developer","topic":"<strong>Topics:<\/strong> Design, WordPress","_links":{"self":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource\/139655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource"}],"about":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/types\/resource"}],"author":[{"embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/users\/1"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/media\/141012"}],"wp:attachment":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/media?parent=139655"}],"wp:term":[{"taxonomy":"resource-topic","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-topic?post=139655"},{"taxonomy":"resource-role","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-role?post=139655"},{"taxonomy":"resource-type","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-type?post=139655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}