[advanced search]
Results from the most recent live auction are here.
20 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Webmaster Tutorials
User Name
Password

Old 11-19-2006, 08:59 AM   · #1
zk0
NamePros Member
 
zk0's Avatar
 
Trader Rating: (1)
Join Date: Jun 2005
Posts: 163
NP$: 52.20 (Donate)
zk0 is an unknown quantity at this point
How to make a special CSS Stylesheet for print

In my article yesterday, when I talked about how important the text on your website or blog is I mentioned that it is a good idea to have different stylesheets depending on if your user wants to print out the text or just read it on his screen. In this post I will show you how you make a special CSS Stylesheet for your users when they print out your homepage. It isn’t hard, in fact it is really easy!

Your HTML code (header) might look something like this:

HTML Code:
<html> <head> <title>Name of page< /title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <link href="style.css" rel="stylesheet" type="text/css"/> </head> <body>


Here you can see your link to your ordinary CSS stylesheet. Now if we want to add a CSS Stylesheet that takes over when your user press on print you must add this little code under the ordinary CSS link code:

HTML Code:
< link rel="stylesheet" type="text/css" href="printstyle.css" media="print"/>


It should look something like this (the code marked in bold is the code you just inserted):

HTML Code:
<html> <head> <title>Labbportalen <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <link href="style.css" rel="stylesheet" type="text/css"/> <link rel="stylesheet" type="text/css" href="printstyle.css" media="print"/> </head> <body>


Now that is fixed! Now you just need to your “printstyle.css” file. Here is an example on how it could look like:

Code:
p { font-family:"Times New Roman", Georgia, serif; font-size:12pt; } img { display:none; } #content {width:100%;}


Your font should be in a serif like Times New Roman. The font size should be set to “pt” and not “px” or “em”. Pt looks best when you print out your text. “Em” and “px” is best when reading on your screen. The “img” tag on this example takes away all the images on your site.

Taken from: How to make a special CSS Stylesheet for print


Please register or log-in into NamePros to hide ads
zk0 is offline   Reply With Quote
Old 11-19-2006, 11:57 AM   · #2
Barrucadu
Formally Mikor.
 
Barrucadu's Avatar
 
Name: Michael Walker
Location: East Yorkshire, England
Trader Rating: (7)
Join Date: Aug 2005
Posts: 2,539
NP$: 164.25 (Donate)
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
Thanks, I was wondering how to have a print stylesheet.

I would give rep but...
Quote:
We're glad that you're fond of this member, but please give some rep points to some other members before giving it to zk0 again.


lol
__________________
Me | Blog | Last.fm | F@h | Archlinux.co.uk

archlinux User
Barrucadu is offline   Reply With Quote
Old 11-19-2006, 01:44 PM   · #3
zk0
NamePros Member
 
zk0's Avatar
 
Trader Rating: (1)
Join Date: Jun 2005
Posts: 163
NP$: 52.20 (Donate)
zk0 is an unknown quantity at this point
Originally Posted by Mikor
Thanks, I was wondering how to have a print stylesheet.

I would give rep but...

lol


Haha thats funny. Thank you
zk0 is offline   Reply With Quote
Old 11-19-2006, 09:15 PM   · #4
DylanButler
NamePros Regular
 
DylanButler's Avatar
 
Name: Dylan Butler
Location: San Diego, CA
Trader Rating: (38)
Join Date: Jan 2006
Posts: 693
NP$: 0.00 (Donate)
DylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to behold
The key here is the media attribute on the link tag.

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

You use the media attribute to specify what styles a specific media will receive.

Media types:
* screen (the default), for non-paged computer screens;
* tty, for fixed-pitch character grid displays (such as the display used by Lynx);
* tv, for television-type devices with low resolution and limited scrollability;
* projection, for projectors;
* handheld, for handheld devices (characterized by a small display and limited bandwidth);
* print, for output to a printer;
* braille, for braille tactile feedback devices;
* aural, for speech synthesizers;
* all, for all devices.
__________________
-Dylan Butler

Coming soon: examp
DylanButler is offline   Reply With Quote
Old 02-17-2007, 04:09 PM   · #5
YesBrilliant
Account Closed
 
Trader Rating: (21)
Join Date: Sep 2006
Posts: 1,075
NP$: 0.00 (Donate)
YesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to all
Originally Posted by Mikor
Thanks, I was wondering how to have a print stylesheet.


The same here.

Thanks for sharing.

travel abroad

Last edited by YesBrilliant : 04-11-2007 at 12:11 AM.
YesBrilliant is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
http://www.mobisitetrader.com/ Get Your Site Linked at LinkedKeywords.com http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 06:41 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0