473,722 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help Me Understand A Printer-Friendly CSS....


Okay, I'd like to create a print-friendly website, so I've been
reading up on how to create print-friendly pages (without duplicating
my site, of course, by having separate versions of each page)....

Apparently one can use JavaScript or CSS for this....

Using CSS, it seems that the "trick" is to use * media="print" * in
the <linktag....

So if I have a hyperlink to a print-friendly page...um, well, what's
that, just the current webpage, only with "print.css" instead of
"default.cs s" in the <linktag??? If so, that would be just having a
duplicate copy of the whole site!

So that can't be how it works, right?

But then, how does it work??

What's that print-friendly hyperlink actually pointing to??

This must be so basic that no one bothers explaining it...but I'm
starting ~95% from scratch, here....

BTW, here's something from my print.css file that's not working for
some reason:

body {
background-color: #fff;
color: #000;
margin: 0;
padding: 40px;
font: normal 12pt/160% Georgia;
}

#header, #menu, #search, #footer {
display: none;
}

a:link, a:visited, a:active {
color: #000;
text-decoration: none;
}

#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;
}

img { display: none; }
That last img thinggy, I'm not so sure about, as well the show URL
thinggy right before it, but the others don't work and yet they look
100% proper to me! What's going on?? My footer still shows up, my
menu shows up, the searchbox shows up, hyperlinks are still underlined
and colored, etc.

ALL ADVICE MUCH APPRECIATED!!
Jun 27 '08 #1
15 2183

Okay, wait a minute...I can get most of that CSS to work now, but

a:link, a:visited, a:active {
color: #000;
text-decoration: none;
still doesn't work as intended...whic h is supposed to not only take
away the underline from hyperlinks, but also make the hyperlinks' URLs
show up in parentheses! Anyone know what I'm missing here? Maybe
that bit of CSS code is supposed to be applied to each link
individually??

Also, I'd still like to understand if a "printer-friendly page"
**isn't** just a duplicate webpage with a print-friendly CSS
associated with it...if not, then how's the browser supposed to know
what to do, when it's already loaded up the default website CSS file?
Jun 27 '08 #2
Prisoner at War wrote:
Okay, I'd like to create a print-friendly website, so I've been
reading up on how to create print-friendly pages (without duplicating
my site, of course, by having separate versions of each page)....

Apparently one can use JavaScript or CSS for this....

Using CSS, it seems that the "trick" is to use * media="print" * in
the <linktag....

So if I have a hyperlink to a print-friendly page...um, well, what's
that, just the current webpage, only with "print.css" instead of
"default.cs s" in the <linktag??? If so, that would be just having
a duplicate copy of the whole site!

So that can't be how it works, right?

But then, how does it work??

What's that print-friendly hyperlink actually pointing to??

This must be so basic that no one bothers explaining it...but I'm
starting ~95% from scratch, here....
No need to link to another page. Every page can simply link to the
print.css sheet. In your page where you link to the style sheets just
put the print.css under the main style sheet. When a browser print
command is invoked it will automatically use the print.css styles. For
example:

<link href="/styles/default.css" rel="styleSheet " type="text/css">
<link href="/styles/print.css" rel="styleSheet " type="text/css"
media="print">

Try it.

See:

http://meyerweb.com/eric/articles/webrev/200001.html
BTW, here's something from my print.css file that's not working for
some reason:

body { background-color: #fff; color: #000; margin: 0; padding: 40px;
font: normal 12pt/160% Georgia; }

#header, #menu, #search, #footer { display: none; }

a:link, a:visited, a:active { color: #000; text-decoration: none; }

#primarycontain er a:after { content: " ( attr(href) ")"; font-size:
11pt; }

img { display: none; }
That last img thinggy, I'm not so sure about, as well the show URL
thinggy right before it, but the others don't work and yet they look
100% proper to me! What's going on?? My footer still shows up, my
menu shows up, the searchbox shows up, hyperlinks are still
underlined and colored, etc.

ALL ADVICE MUCH APPRECIATED!!
Taken out of context of everything else in your page it's pretty
difficult to even comment on this. Post a link to the online page.

--
Ed Mullen
http://edmullen.net
There's no trick to being a humorist when you have the whole government
working for you. - Will Rogers
Jun 27 '08 #3
On Apr 20, 11:33 am, Ed Mullen <e...@edmullen. netwrote:
>

No need to link to another page. Every page can simply link to the
print.css sheet. In your page where you link to the style sheets just
put the print.css under the main style sheet. When a browser print
command is invoked it will automatically use the print.css styles. For
example:

<link href="/styles/default.css" rel="styleSheet " type="text/css">
<link href="/styles/print.css" rel="styleSheet " type="text/css"
media="print">
Ahh, actually, that's the ~5% know-how I do have, that I had been
alluding to...I actually do have those tags up, just so...what I'm
wondering is whether CSS can somehow create a print-friendly version
of the webpage *on screen* without my creating a copy of the original,
only with a print-friendly CSS file that's called....
Try it.

See:

http://meyerweb.com/eric/articles/webrev/200001.html
Thanks, Ed, but I actually did come across it already -- so let me
better phrase my situation:

I have a hyperlink that says "printer-friendly page" and I would like
it to point to a WYSIWYG page. Does that mean I would have to create
another webpage, only with a printer-friendly CSS file controlling it,
or can CSS somehow "generate on its own" such a page?

IOW, a kind of on-screen print-preview page, like what you get with a
time.com article...now are such pages just printer-friendly copies of
the original webpage, or has CSS been used to "automatica lly generate"
them somehow??
Taken out of context of everything else in your page it's pretty
difficult to even comment on this. Post a link to the online page.
Ach, it's not online yet...but how about that code for the hyperlinks
and URLS, respectively,

a:link, a:visited, a:active {
color: #000;
text-decoration: none;
}

#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;
}
--
Ed Mullenhttp://edmullen.net
There's no trick to being a humorist when you have the whole government
working for you. - Will Rogers

Jun 27 '08 #4
Prisoner at War wrote:
On Apr 20, 11:33 am, Ed Mullen <e...@edmullen. netwrote:
>>
No need to link to another page. Every page can simply link to the
print.css sheet. In your page where you link to the style sheets just
put the print.css under the main style sheet. When a browser print
command is invoked it will automatically use the print.css styles. For
example:

<link href="/styles/default.css" rel="styleSheet " type="text/css">
<link href="/styles/print.css" rel="styleSheet " type="text/css"
media="print ">

Ahh, actually, that's the ~5% know-how I do have, that I had been
alluding to...I actually do have those tags up, just so...what I'm
wondering is whether CSS can somehow create a print-friendly version
of the webpage *on screen* without my creating a copy of the original,
only with a print-friendly CSS file that's called....
You missed the important point in what I said and what the cited page
says. The /USER'S BROWSER/ knows that there is a print style sheet and
will use it when the user invokes print or print preview (there's your
"print-friendly version of the webpage *on screen*"). The browser uses
your CSS style sheet to do that.
>
>Try it.

See:

http://meyerweb.com/eric/articles/webrev/200001.html

Thanks, Ed, but I actually did come across it already -- so let me
better phrase my situation:

I have a hyperlink that says "printer-friendly page" and I would like
it to point to a WYSIWYG page. Does that mean I would have to create
another webpage, only with a printer-friendly CSS file controlling it,
or can CSS somehow "generate on its own" such a page?
No no no! You're missing the point. All of this is handled by the
user's browser. As I already said, put link the print.css in every one
of your Web pages. If the user wants to print (or print preview) a page
his browser will use the styles in the print.css style sheet.
>
IOW, a kind of on-screen print-preview page, like what you get with a
time.com article...now are such pages just printer-friendly copies of
the original webpage, or has CSS been used to "automatica lly generate"
them somehow??
Sites that use that "Click for printer-friendly page" are probably
generating a new page on-the-fly server-side using PHP, Perl, etc.
Frankly, I have never seen the utility in that from a user stand-point.
The same is achieved by simply linking a style sheet and letting the
user choose "print preview" if they want to see it before printing it.
If you use the technique I'm talking about it is much less complicated
design-wise, takes no fancy server-side "stuff" and takes less time.
Using a print.css style sheet doesn't require building and then loading
a whole different page. Nor opening it in a new window, which I also hate.

But, if you really want to use that method maybe someone else can tell
you how.
>Taken out of context of everything else in your page it's pretty
difficult to even comment on this. Post a link to the online page.

Ach, it's not online yet...but how about that code for the hyperlinks
and URLS, respectively,

a:link, a:visited, a:active {
color: #000;
text-decoration: none;
}

#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;
}
So put up the unfinished code; we don't care if it isn't finished, it
needs to be seen in context. Out-of-context code can't be reliably
de-bugged.

--
Ed Mullen
http://edmullen.net
Have you noticed since everyone has a camcorder these days no one talks
about seeing UFOs like they used to?
Jun 27 '08 #5
Prisoner at War wrote:
BTW, here's something from my print.css file that's not working for
some reason:

font: normal 12pt/160% Georgia;
Looking more closely I'm perplexed by that construct. Where's you get that?
#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;
You got me on that construct. Never seen such a thing.
}

img { display: none; }
That last img thinggy, I'm not so sure about, as well the show URL
thinggy right before it, but the others don't work and yet they look
100% proper to me! What's going on?? My footer still shows up, my
menu shows up, the searchbox shows up, hyperlinks are still underlined
and colored, etc.

ALL ADVICE MUCH APPRECIATED!!
Maybe someone else will chime in here.

--
Ed Mullen
http://edmullen.net
Photons have mass? I didn't even know they were Catholic.
Jun 27 '08 #6
On Apr 20, 3:31 pm, Ed Mullen <e...@edmullen. netwrote:
>

You missed the important point in what I said and what the cited page
says. The /USER'S BROWSER/ knows that there is a print style sheet and
will use it when the user invokes print or print preview (there's your
"print-friendly version of the webpage *on screen*"). The browser uses
your CSS style sheet to do that.

No no no! You're missing the point. All of this is handled by the
user's browser. As I already said, put link the print.css in every one
of your Web pages. If the user wants to print (or print preview) a page
his browser will use the styles in the print.css style sheet.
Yes, when the user hits the browser's print button, the browser knows
that there's a CSS file just for printing the webpage.

I was wondering if there's a way to give the user a WYSISYG page, a
preview of the printout, independent of the operating system's own
print preview capability...ap parently it's possible; I'm getting the
idea from Chapter 14 of "Beginning CSS Web Development: From Novice to
Professional" by Simon Collison...unfo rtunately, he doesn't explain
this step-by-step, assuming by that point (page 320) that one's
already got a lot of the necessary background knowledge, I guess.

He specifically uses the Nottingham Science City website as a case
study (http://www.science-city.co.uk, though there's no longer a
"Print Version" link for some reason), where the site's got a black
background but hitting a print-friendly hyperlink brings up the same
page, only denuded of "printer-hostile" aspects like that black
background....

Sorry I'm having difficulty articulating all this!
Sites that use that "Click for printer-friendly page" are probably
generating a new page on-the-fly server-side using PHP, Perl, etc.
Frankly, I have never seen the utility in that from a user stand-point.
The same is achieved by simply linking a style sheet and letting the
user choose "print preview" if they want to see it before printing it.
If you use the technique I'm talking about it is much less complicated
design-wise, takes no fancy server-side "stuff" and takes less time.
Using a print.css style sheet doesn't require building and then loading
a whole different page. Nor opening it in a new window, which I also hate.

But, if you really want to use that method maybe someone else can tell
you how.
Hmmm, so that's all server-side, huh?? Makes sense, then!

But such a thing does seem possible client-side, too...again, I've got
that book but unfortunately the Nottingham Science City website
referenced doesn't have a print-friendly link anymore for some reason
so I don't think looking at the (X)HTML would help....
So put up the unfinished code; we don't care if it isn't finished, it
needs to be seen in context. Out-of-context code can't be reliably
de-bugged.
Um, okay...

* * * * * * * * * * * * * * * *

body {
background-color: #fff;
color: #000;
margin: 0;
padding: 40px;
font: normal 12pt/160% Georgia;
}

#header, #menu, #search, #footer {
display: none;
}

img { display: none; }

a:link, a:visited, a:active {
color: #000;
text-decoration: none;
}

#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;
}

* * * * * * * * * * * * * * * *
So far, it's only the last two that don't seem to work, or have any
effect at all.
--
Ed Mullenhttp://edmullen.net
Thanks again, Ed! I'm curious...how are you using CSS for your site?
Have you noticed since everyone has a camcorder these days no one talks
about seeing UFOs like they used to?
True!!
Jun 27 '08 #7
On Apr 20, 3:33 pm, Ed Mullen <e...@edmullen. netwrote:
Prisoner at War wrote:

<SNIP>

Looking more closely I'm perplexed by that construct. Where's you get that?
#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;

You got me on that construct. Never seen such a thing.
It's from Simon Collison's "Beginning CSS Web Development: From Novice
to Professional" (2006, Apress)...he doesn't explain it much since
it's on pages 323-4 and so probably assumes a high level of technical
know-how by then...it's supposed to get the browser to display, on a
printer-friendly WYSIWYG page, the URLs of your hyperlinks within
parentheses, after the text that would normally be underlined as
hyperlinks (previously removed by a separate bit of CSS code)....
Maybe someone else will chime in here.
Sure hope so! Seems like a real niffty lil' usability feature to
implement! Ahhh, "craftsmanship" .... ;-)
--
Ed Mullenhttp://edmullen.net
Photons have mass? I didn't even know they were Catholic.
Jun 27 '08 #8
On Apr 20, 4:04 pm, Prisoner at War <prisoner_at_.. .@yahoo.comwrot e:
>

<SNIP>

* * * * * * * * * * * * * * * *

body {
background-color: #fff;
color: #000;
margin: 0;
padding: 40px;
font: normal 12pt/160% Georgia;

}

#header, #menu, #search, #footer {
display: none;

}

img { display: none; }

a:link, a:visited, a:active {
color: #000;
text-decoration: none;

}

#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;

}

* * * * * * * * * * * * * * * *

So far, it's only the last two that don't seem to work, or have any
effect at all.
Correction: the penultimate bit of code does work -- hyperlink
underlines are removed and hyperlink "coloring" as well...only it's
still "live" and can be clicked to the URL referenced...an y way to
turn that off, too?
<SNIP>
Jun 27 '08 #9
On Apr 20, 4:09 pm, Prisoner at War <prisoner_at_.. .@yahoo.comwrot e:
On Apr 20, 3:33 pm, Ed Mullen <e...@edmullen. netwrote:
Prisoner at War wrote:
<SNIP>
Looking more closely I'm perplexed by that construct. Where's you get that?
#primarycontain er a:after {
content: " ( attr(href) ")";
font-size: 11pt;
You got me on that construct. Never seen such a thing.

It's from Simon Collison's "Beginning CSS Web Development: From Novice
to Professional" (2006, Apress)...he doesn't explain it much since
it's on pages 323-4 and so probably assumes a high level of technical
know-how by then...it's supposed to get the browser to display, on a
printer-friendly WYSIWYG page, the URLs of your hyperlinks within
parentheses, after the text that would normally be underlined as
hyperlinks (previously removed by a separate bit of CSS code)....
Clarification: last sentence should read, "...after the text that
would normally be underlined as hyperlinks (the underlines previously
removed by a separate bit of CSS code)...."
<SNIP>
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9272
by: whirl | last post by:
Hi. I really need some help on this one please. I am trying to print a 12.1 x 12.1cm box to my printer. I have found this code bit I just cant work out what the numbers mean. I know they are something to do with X/Y coordinates but what do the values actually mean . Printer.Line (1000, 2000)-(5000, 4000), vbRed, B
3
2979
by: Mahmood Ahmad | last post by:
Hello, I have written a program that reads three types of records, validates them acording to certain requirements and writes the valid records into a binary file. The invalid records are supposed to be reported on the printer but I have commented those pieces of code and have got those records printed on the screen. I am using Microsoft Visual C++ 6.0 on Microsoft XP (Home) platform. I am facing some problems in getting desire...
5
3353
by: john | last post by:
Here is the short story of what i'm trying to do. I have a 4 sided case labeling printer setting out on one of our production lines. Now then i have a vb.net application that sends data to this printer using a RawPrinterHelper class that i found I believe in the msdn. the class works wonderfully when I send stright text data (in the correctly formated string that the sato printer requires.) but when i go to send a image nothing is...
2
3208
by: PC User | last post by:
I found some VB code to printout a richtext field and I'm trying to adapt it to MS Access 2000. I think there might be some small changes to make the adaption between VB versions. Also my OS is Windows XP. The website I found the code is: http://www.developerfusion.com/show/244/ See the code below. There is also some code found at http://www.freevbcode.com/ShowCode.asp?ID=1028 I would appreciate someone's help in getting this to work. ...
0
1341
by: chunming | last post by:
hi, Dear Leader(i think you are enough for my project leader), I have a very fancy question and I need your help: I use C#.net to develop a Point of Sales system, use Epson Tm-t88 printer( POS printer), connected w/ :LPT1, and now: I have following problem: when i finished installing the driver, the test page is ok If I use notepad to print something by choose this printer in printer dialog, it works fine,
3
1427
by: trint | last post by:
Here is the error: An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll Additional information: Not found here is the code: string printerName = ""; foreach (ManagementObject printer in searcher.Get()) {
0
1125
by: Anthony Nystrom | last post by:
I am having trouble with changing printer settings before I raise either the pagesetup dialog or the print preview dialog... Changing the printer name is easy, but I am also trying to change the paper size.... This particular paper size is 30386 Video Top is specific to the printer driver itself... Any sample code as to how to both change the printer and paper size as well as oriention so that the user doesn't have to? This particular printer...
11
9888
by: pamelafluente | last post by:
I am doing my own PrintDialog, and have placed there a combo with the printer names, as in the PrintDialog provided by VB.NET. Here is the question: how do I open the native windows printer dialog for the current printer, so that my current PrintDocument.PrinterSettings will be set according to the User choices ? Thanks -Pamela
13
1817
by: robert10 | last post by:
Hi, I have recently added some code to my form in regards to resizing an image on Print. I have an image that does print correctly after its been resized, howver i'm needing to use it as a backgound image which will have variable text written in front of it. I am having trouble geting labels and text boxes to print, along with the inlarged image that is printing. The labels and text boxes need to appear infront of the image. And where do I...
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.