Wednesday 26 September 2012

Print Style Sheet : What is Print Style Sheet ? How to Set up Print Style sheet ?

Print Style Sheet : What is Print Style Sheet ? How to Set up Print Style sheet ?


What is Print Style Sheet ?

A print stylesheet formats a web page so when printed, it automatically prints in a user-friendly format. Print stylesheets have been around for a number of years and have been written about a lot. Yet so few websites implement them, meaning we're left with web pages that frustratingly don't properly print on to paper.

How to set up Print Style sheet ?

The best method is to start from scratch and rely on the default style sheet of the browser, which takes care of the printed output pretty well by default. In this case, insert all declarations for printing at the end of your main style sheet, and enclose them with this distinct rule:

@media print {
   …
}








For this we have to do two things 

1. Include all screen styles in the separate @media screen {…} rule;
2. Omit the media type for the condensed style sheet: 
<link rel="stylesheet" href="css/style.css"/>

or we can write like this :

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

 Now ready to add print style sheet ? Thinking about how to write styles?? 
Check the below example: 

   * Remove unwanted elements */
#header, #nav, .noprint
{
display: none;
}

/* Ensure the content spans the full width */
#container, #container2, #content
{
width: 100%; margin: 0; float: none;
}

/* Change text colour to black (useful for light text on a dark background) */
.lighttext
{
color: #000
}

/* Improve colour contrast of links */
a:link, a:visited
{
color: #781351
}


Every thing done, Still have an issue with printing background colors  & Images ?
Here is the solution :

How to get Background Colors & Images in Pirnt ? 
How to get Background Colors & Images in Print pdf file created in Chrome ? 

It's simple,

Add 
"-webkit-print-color-adjust:exact; " property in body styles.

Ex:
body {background-color:#fff; font-family:arial; font-size:15px; background:white; -webkit-print-color-adjust:exact;

 




11 comments:

  1. Are you looking for reputed training institute to pursue web design training? Then, FITA will be the ideal destination. We offer high quality best website designing training in Chennai which help you to start your career as web designer.

    ReplyDelete
  2. Here i had a opportunity to learn about print style sheet, its really a good post thanks for sharing this to my knowledge
    Web design training in Chennai

    ReplyDelete
  3. HTML5 Courses in Chennai Training

    Hi, Thanks for sharing this valuable blog.I was really impressed by reading this blog. I did HTML5 Training in Chennai at reputed HTML5 Training Institutes in Chennai. This is really useful for me to make a bright future in designing field.

    HTML Training in Chennai

    ReplyDelete

  4. Thanks for sharing your view to our knowledge’s, its helps me plenty keep sharing…
    DOT NET Training in Chennai

    ReplyDelete

  5. This post having niche information to make myself updated. Angularjs is the extended version of HTML with new attributes. It’s a JavaScript framework that can be added to an html page with a tag of script.if you want to study
    Angular training in chennai get into FITA.

    ReplyDelete
  6. Digital Marketing Training in Chennai

    Thanks for sharing this informative blog. Recently I did Digital Marketing courses in Chennai at a leading digital marketing company. It's really useful for me to make a bright career. If anyone wants to get Digital Marketing Training in Chennai visit infiniX.

    Regards...

    Digital Marketing Course in Chennai

    ReplyDelete
  7. It helps the software developers and programmers to validate software application performance and behavior before deployment.Nice article.
    html5 Training in chennai | html5 Training chennai

    ReplyDelete
  8. Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for Learners..
    Web designing Training in chennai | Web designing Training chennai

    ReplyDelete

  9. Thanks Admin for sharing such a useful post, I hope it’s useful to many individuals for developing their skill to get good career.
    Regards,
    Python Training in Chennai|Python Training

    ReplyDelete
  10. This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing...
    Regards,
    sas training in Chennai|sas course in Chennai

    ReplyDelete

  11. I love the information about web design you provide here and can’t wait to take a look when I get home.
    I love the information you provide here and can’t wait to take a look when I get home.

    ReplyDelete