Free content for your website, newsletters or ezines. Free articles for reprint | Lbry.com
corner Set as Homepage   |   Add to Favourites corner
 
Search for
Need more search features? Go to Advanced Search
 
 
Article Categories
Advertising
Direct Mail, PPC, Word of Mouth
Advice
Affiliate Programs
MLM
Arts
Auto & Trucks
Auto Leasing, Diesel vs. Gasoline Vehicles
Awards
Beauty, Personal Care & Grooming
Business & Finance
Finance, Management, Marketing, Sales
Careers
Communications
Computers & Internet
CD Duplication, Computers FAQs
Copywriting
EBooks
ECommerce
Education
Email
Entertainment
Environment
Family
Child Care
Food & Drink
Cooking & Recipes
Free
Furniture
Office Chairs
Gadgets & Gizmos
Games
Gardening
Gifts
Government
Health
Hair Loss, Headaches, Healthy Eating, Natural Cures
History
Hobbies
Boat Acquisition
Home Business
Home Improvement
Humour
Internet
Blogs, CGI, CSS, DHTML, HTML, Javascript, RSS
Kids and Teens
Law
Marriage
Men's Issues
Metaphysical
Motivational
Music & Movies
Newsletters
Online Business
Organization & Time Management
Parenting
Personal Security & Wellness
Credit Repair, Life Insurance
Pets & Animals
Cats, Dogs
Politics & Government
Press Releases
Psychology
Publishing
Real Estate
Home Mortgage
Recreation & Sports
Fitness, Mountain Biking, Tennis
Reference
Relationships
Religion & Faith
Scams
Science
Weather
Search Engines
Link Popularity, SE Optimization, SE Positioning, SE Tactics, Sitemaps
Self Help
Sexuality
Shopping
Signs & Astrology
Society
Work Life
Technology
Bluetooth, Podcasting
Travel & Adventure
Beach Vacations, Ski Vacations
True Life Stories
Websites
Domain Names, Site Promotion, Web Development, Web Hosting
Weight Loss
Women's Issues
Writing
 
CSS Print Media Tutorial
By Karl Regis | Published  11/28/2005 | | Unrated
CSS Print Media Tutorial
Karl Regis
Karl Regis is a student studying Computer Science. He is continually developing a css tutorial website in order to gain a better understanding of cascading style sheets and pass this knowledge on to others. Css Help is found here: http://www.css-help.com We welcome css tutorial submissions, css experiments and helpful advice.  

View all articles by Karl Regis


So you've made yourself a cutting edge web page. What next ? Well maybe you want your visitors to be able to print pages in a certain style. Heavy graphical content can be removed, background colour changed and navigation items removed, infact anything to make a printer friendly version of your page. All this can de done with CSS.

Printer friendly pages with CSS
CSS can effectively be used to create formated documents ready for print.
This is quite a simple process and all we have to do is create and attach a second style sheet with the attributes required for our print output. Therefore we have a stylesheet that controlls what you see on the screen and a style sheet that controls what is printer. Easy......

Markup changes
So, we will have already attached an external stylesheet in the head code of our document. It should look something like this:



The tag here has an attribute called media which can have a variety of options such as screen or print. For a full description of media types please view our glossary here.

Now, if we want to separate our media into two types - one for the screen and one for print we must alter our code:





We have now defined a separate style sheet for both screen and print.

The css sheets are now called screen.css and print.css. This means when a web browser requests your web page screen.css kicks in for your screen display. When a request is made for a print preview or print the style is defined by print.css.

This is not an automatic process and we will have to write a new style sheet called print.css that works in accordance with your original html document.

In the next section we look at the CSS involved in setting up a page for print output.

CSS Changes
Lets now take a close look at the simple changes we need to make in our stylesheet and how we can create an individual print sheet.

Now is the time to define exactly what we want to achieve in our print output. Maybe we want our website header and logo to be appear on screen but be omitted on paper.

The easiest way to achieve this is create a class or id called 'header' and define a different style for screen.css and print.css.

Lets have a look at how the code may look:

Your header id for screen.css may look like this:

#div header {
font-family:arial;
margin: 0px 0px 2px 2px;
font-size: large;
font-weight: bold;
background-colour: #000000;
border-colour: #ffffff 1px solid;
}

Your header id for print.css may look like this:

#div header {
font-family:arial;
font-size: 20px;
font-weight: bold;
}

The CSS code for screen.css defines font, margin, font size, font weight, background colour and border colour.

The CSS code for print.css defines only the font, font size and font weight. To save the visitor ink we have omitted the background and border and reduces the font size.

If your site is heavy on animated banners or flash movies we can apply a similar technique to allow the banners to be shown on the screen only.

Typical markup for you advertisment movies could be like this:






Your screen.css stylesheet could contain all kinds of attributes for the advertisment such as border colour, drop shadows and position.

In your print.css stylesheet you would want to omit the advertisement from printing so in you would place the following:

#div.ads {
display:none;
}

This CSS code will illiminate the advertisement from the print output.

Hope this helps:

http://www.css-help.com
Note: Republishing this article is permitted in the following conditions:
 
author by-lines are kept intact and unchanged. Hyperlinks and/or URLs provided by authors must remain active.
 
 
a link to the Lbry.com site is required in the use of articles either as print or an active url on the articles web page as below:
[ Article from Lbry.com ]
How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Send to Author Post on Site

 
Comments


Article Options
Most popular articles

»

Dementia: Will I Get It?

By N/A | Published 12/31/1969 | Health | Rating:
In the article Dementia: Just What Is It, we have learned about a frightening term, Dementia, and just what it is or, rather, how it manifests itself in the human condition. I gave 5 examples from my personal knowledge, including myself.
 
  Read the full article   Print this article  
Report An Error    

»

Triumphing Over Tantrums

By N/A | Published 12/31/1969 | Family | Rating:
Patty Hone
 
  Read the full article   Print this article  
Report An Error    

»

Checked Into Nirvana. Where Is Joy?

By N/A | Published 12/31/1969 | Metaphysical | Rating:
Eckhart Tolle lived upto his twenty ninth year in a state of almost continual anxiety interspersed with periods of suicidal depression. Then he woke up one night with a feeling of absolute dread. The silence of the night, the vague outlines of the furniture in the dark room, the distant noise of a passing train - everything felt so alien, so hostile, and so utterly meaningless that it created in him a deep loathing of the world. "I cannot live with myself any longer." This was the thought that kept repeating itself in his mind. Suddenly he became aware that if he could not live with himself, there had to be two - he and the "self" he could not live with. He was stunned by the realization. He became enveloped by powerful feelings.
 
  Read the full article   Print this article  
Report An Error    

»

Celebrex Law Suits Looking Like a Strong Case

By N/A | Published 12/31/1969 | Law | Rating:
There is no data as yet that indicates how many former patients of Pfizer's anti-inflammatory and painkilling drug are filing Celebrex law suits, but given the magnitude of the company's perceived crime it is likely that there will be very many. And even a quick perusal of the alleged behaviour of the company regarding this drug seems to point to Celebrex law suits being something of a fait accompli.
 
  Read the full article   Print this article  
Report An Error    
No popular articles found.
 
Become an Author
 
Are you a writer and you want your work published?
 
 
Do you have a website and need free publicity?
 
 
Sign up for free as a Lbry.com author and have your articles published in no time!
Click here to become an author
 
Advertising
 
 
 
 
Lbry.com Sponsors