I am using the following <div style=“page-break-after: always”> code to create line breaks when someone decides to print out our online documentation.
It works in IE but not in Firefox. Does anyone know of equivalent CSS code for Firefox???
I am using the following <div style=“page-break-after: always”> code to create line breaks when someone decides to print out our online documentation.
It works in IE but not in Firefox. Does anyone know of equivalent CSS code for Firefox???
So I haven’t received any answers. Does ANYONE know?! Please!
Give me a few and I’ll take a look at it.
Bu in the meantime, why isn’t this in an external print stylesheet?
Also, can you post a link to the page in question?
So here is the page I am talking about: example
My problem occurs when you try to print this page. So go to File > Print Preview to see what I mean.
The “Creating New Draws” table should begin on a brand new page and in Internet Explorer it works perfectly however it doesn’t work in Firefox.
So I am looking for equivalent code (IF such exists) that is supported by Firefox and IE simultaneously.
FYI, it works in Opera 9.01/Linux, too.
I’ve got it to work in Firefox (using page-break-before
), but I had that in a separate print style sheet. Try moving it to a such and see if it helps.
And if you don’t move it to a separate style sheet, it doesn’t work in Opera?
It works as-is in Opera. It looks as if Firefox may not be applying the inline style for media="print"
. That’s why I suggested moving your CSS rule to an external style sheet or a STYLE element with an explicit media="print"
, to see if that solves the problem.
I remember having some problem with Firefox when I did this, but it was a while back and I’ve forgotten the details. It works now, at any rate, and I’m using an external style sheet with media="print"
.
So I have the following external CSS set up and it still only works only in Internet Explorer. What am I doing wrong? I need this to work in FireFox and Netscape as well and it does not. HELP!
[B]@media print {
div.page_break{
page-break-before: always;
}
}
@media screen {
div.page_break{
page-break-before: always;
}
}[/B]
I’m no expert on print stylesheets, but why do you have Microsoft’s browser scrollbar styles (which only work in IE, Opera and Konqueror) in your printer stylesheet?
This is the results page I got from the W3C CSS validator (direct input check):
I think Tommy was talking about doing this:
<link rel="stylesheet" type="text/css" href="print.css" media="print">
rather than using @media print.
I know I might have other problems in my stylesheet, but I am not into the complete validation part yet and my question was specifically in regards to making page breaks work in Firefox and Netscape (it only works in Internet Explorer for me right now).
If I use this code
<link rel=“stylesheet” type=“text/css” href=“print.css” media=“print”>
then I need to have 2 separate style sheets - one for print and one for the web.
And by using this code
[B]@media print {
div.page_break{
page-break-before: always;
}
}
@media screen {
div.page_break{
page-break-before: always;
}
}[/B]
I can have one stylesheet only.
But all of this still does not solve my problem of how to get Firefox and Netscape to display proper page breaks.
Validating the code first might help :).
Sorry I can’t stick around and offer you some more concrete advice right now. I have to schedule a doctor’s appointment (my cat bit me pretty deep on my right hand this morning, which makes typing very difficult) and pick up the prescription the ER wrote out for me, so not only do I have to leave soon, but I will be gone for a while.
The problem is that CSS is pretty picky with regard to errors and a lot of browsers will just give up after even a little bit of bad syntax. The code you are looking at may be perfectly valid but not being applied because of an error way back at the beginning of your stylesheet.
In my experience, keeping my stylesheet rules valid as I insert them is even more important than making my xhtml valid. Many browsers are quite forgiving of poor xhtml code but will choke on a small bit of bad CSS code, or at least that is my experience.
So I suggest you validate that CSS before trying anything else.
What’s wrong with having two stylesheets? I think you’ll a lot of sites have a completely separate print stylesheet and the print version doesn’t need to be that complicated.
If things don’t work the way you intended, always make sure that your markup and CSS validate before proceeding. If you are experienced and know what you’re doing, you may leave certain validation errors that you know won’t matter. But that’s only if you’re at Advanced Guru Level or higher.
Using separate style sheets for screen and print is very common. I actually prefer it that way, but YMMV. It’s nothing to be afraid of, though.
ok so my stylesheet validates now, i am still using the same style sheet for both print and media (which is correct and should not be a problem)…however this still has not resolved my problem in Firefox and Netscape.
page breaks are still being ignored… any relevant tips?
As using separate stylesheets has been the only suggestion put forward so far, why don’t you actually try it instead of assuming it won’t work?
Do these divs have end tags? Do the divs have any content? Does the link to the stylesheet have a media=“” attribute (and if so, what’s its value?)?
It’s hard to give advice when we don’t see the actual code.
So here is an example of my code that does NOT work in Firefox but works in IE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table>
<tr>
<td>
<div style="page-break-after: always">
This should print on page 1
</div>
</td>
</tr>
<tr>
<td>
This should print on page 2
</td>
</tr>
</table>
</body>
</html>
And I figured out that the problem in Firefox was due to the fact that the <div> tag was inside a <table> tag. The following code works perfectly:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div style="page-break-after: always">
This should print on page 1
</div>
This should print on page 2
</body>
</html>
So while I have solved this partially, now I need to find out how to get a table printed partially on one page and another in Firefox.
I’ve solved my own problem!!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table>
<tr style="page-break-after: always">
<td>
This should print on page 1
</td>
</tr>
<tr>
<td>
This should print on page 2
</td>
</tr>
</table>
</body>
</html>