473,698 Members | 2,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing headers for an HTML only when printing

Hi,
is there any way to write a header in each HTML page when printing them
while leaving the header only on top of the file when viewing it? I
mean, I have a file that looks like this:

TITLE

TABLE1

TABLE2

TABLE3

TABLE4

and each table is being printed on a separate page using CSS
page-break-after. What I want to do is that, when I print it, the
result will be something like:

TITLE

TABLE1

-page break-

TITLE

TABLE 2

-page break-

.... and so on.

Is there any way?
Thanks :)

LuTHieR

Jul 17 '06 #1
4 3316

LuTHieR wrote:
is there any way to write a header in each HTML page when printing them
while leaving the header only on top of the file when viewing it?
Sort of.

You can do this with CSS using the @media print rule
http://www.w3.org/TR/CSS21/media.html#at-media-rule

With this you can mark up sections of your page as "print only" and
"no-print" with a simple class attribute.

..print-only{ display: none; visibility: hidden; }

@media print {
.print-only { display: inherit; visibility: display; }
.no-print { display: none; visibility: hidden; }
}
Now this isn't exactly what you wanted - there's no way in CSS to say
"repeat on every page" (you can do this with XSL:FO and PDF, but not
HTML). So you'll still have to duplicate your "print only" caption on
each pagge manually.

Jul 17 '06 #2

Andy Dingley wrote:
LuTHieR wrote:
is there any way to write a header in each HTML page when printing them
while leaving the header only on top of the file when viewing it?

Sort of.

You can do this with CSS using the @media print rule
http://www.w3.org/TR/CSS21/media.html#at-media-rule

With this you can mark up sections of your page as "print only" and
"no-print" with a simple class attribute.

.print-only{ display: none; visibility: hidden; }

@media print {
.print-only { display: inherit; visibility: display; }
.no-print { display: none; visibility: hidden; }
}
Now this isn't exactly what you wanted - there's no way in CSS to say
"repeat on every page" (you can do this with XSL:FO and PDF, but not
HTML). So you'll still have to duplicate your "print only" caption on
each pagge manually.
Many thanks for the answer, but I still don't know how to use it
exactly, I never used @media and am not really sure of its usage.

Assuming I have something like

<strong>TITLE </strong>
<table>....</table>
<table>....</table>
<table>....</table>

how should I apply the styles in order to make the title print before
every table? I guess it's got to be something like

<span class="print-only">TITLE</span>
<table>....</table>
<span class="print-only">TITLE</span>
<table>....</table>
<span class="print-only">TITLE</span>
<table>....</table>

but I'm not really sure. Could you please explain it a little more?
Thanks again,

LuTHieR

Jul 17 '06 #3

LuTHieR wrote:
how should I apply the styles in order to make the title print before
every table? I guess it's got to be something like

<span class="print-only">TITLE</span>
<table>....</table>
That's pretty much it (although I'd use <h2or something more
meaningul rather than just <span>)

Jul 17 '06 #4

Andy Dingley wrote:
LuTHieR wrote:
how should I apply the styles in order to make the title print before
every table? I guess it's got to be something like

<span class="print-only">TITLE</span>
<table>....</table>

That's pretty much it (although I'd use <h2or something more
meaningul rather than just <span>)
Thanks :)

Jul 27 '06 #5

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

Similar topics

6
17403
by: Alec | last post by:
Hi, I am trying to print an HTML page from Internet Explorer and it always put the page title and page count at the top of the page. How can I disable printing page title and page count? Thanks.
1
2173
by: adiel | last post by:
Hello everyone. The problem is when printing, the text gets cut half way and prints the other half on to the next page when printing using internet explorer and an asp.net datagrid. I am sure there must be a simple fix to stop the text from getting cut in half like this when using the asp.net datagrid. Any ideas? Thanks before hand, Adiel
4
3351
by: Jack Russell | last post by:
Any bright ideas on how I can calculate how wide a piece of text will be when printing. When writing text to the screen in graphics mode I put it in a invisible text box to get its height and width (as suggested on this group). But obviously I cannot do that with the printer. Thanks
8
12773
by: CJM | last post by:
What is the best way to force a page break when printing from a browser? A page in my application generates a series of tables which are usually less than will fit on a page of A4. Ideally I want to introduce a page break between each table when printing. I'm not sure what options I have available. I know there is some support in CSS but I'm no sure on the details or effectiveness. Thanks in advance...
6
2124
by: J Ames | last post by:
I have an ASP.NET (VB) form that has two drop downs, a horizontal rule and a button. The button invokes a stored procedure and several tables are created on the page with data populated. I want to create a link to print the page, but I don't want the drop downs or the button to print, only the tables. How can this be done? I know how to use a CSS file to disallow the entire page from being printed, but I don't know how to apply this to...
5
14189
by: fjanon | last post by:
Is there a way to remove the default footer/header from the printed page when printing a page from HTML/Javascript in IE 6? I want to use letterhead paper and I have to remove manually the header/footer from the default printer setting. I know that IE has lots of options/features, I spent a good time on MSDN but could not find anything. TIA Fred
0
1027
by: BlueComet | last post by:
Does anyone know of a solution to avoiding right-floated elements (like a pull quote) from getting clipped at the top when printing, when it occurs between page breaks? Increasing the top margin of the browser's page setup works but that would be a user-controlled parameter.
7
9027
by: bbatson | last post by:
Hello, I have a fairly extensive report with 10 or so subreports. I've found that random lines (simply used to separate column headers from data) are at random disappearing when printing to a PDF file. They show up when viewing in Print Preview mode within Access (2007) but for some reason are not always showing up in the PDF report. It's especially weird because the line will be in the same grouping and will show up for some sets of data...
8
6129
by: deegeorge | last post by:
Hi, I am printing a word document. When printing in the Print statement its showing a dialog box Save File as. How can i hide this dialog box.... Reply fast... Deeps
0
8609
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
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8899
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
7738
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
6528
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
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.