Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing a specific table on a webpage

Status
Not open for further replies.

dugen

Programmer
Jun 16, 2003
59
US
Hi,

I am trying to print a single table on a webpage that has about 5 tables on it.

i am using this code in my style sheet:

table {display: none;}
#printTable {display: block;}


and i am linking the style sheet using this code:

<link rel="stylesheet" media="print" href="print.css">

Here is the table id that i am using:
<table id="printTable">


When i print out the webpage using this code, i get nothing but a blank page. Not sure what i am doing wrong.


 
It should work the way you want it to work. Browsers might have problems with tables, because tables are compounded structures. Try shoving your table in a div and switch between hiding and showing the div. Also, if possible, could you create a simple page exhibiting this problem? Just because it seems like something else might be causing your page to come out blank.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Here is a sample page that i am having the same problem with:


<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" media="print" href="print-style.css">
</head>

<body>
<p>TEST</p>

<p>TEST </p>

<p>Dont Print THis </p>

<table id="printTable" style="height: 737px; border: #cccccc 2px solid" cellspacing="0" cellpadding="2" width="640" align="center" border="2">
<tr align="center" bgcolor="#646f53">
<td style="width: 500px" valign="middle" align="center"><p class="style1"><strong><font color="#ffffff"><span style="font-family: Arial">Name</span></font></strong></p></td>
<td style="width: 500px" valign="middle" align="center" class="mai"><p class="style1" align="center"><strong><font color="#ffffff"><span style="font-family: Arial">Description</span></font></strong></p></td>
<td style="width: 500px" valign="middle" align="center"><p class="style1"><strong><font color="#ffffff"><span style="font-family: Arial">Price</span></font></strong></p></td>
</tr>
</table>



</body>
</html>



Here is the file print-style.css:

table {display: none;}
#printTable {display: block;}
 
Using your example I cannot reproduce your error on either FF or IE. Can you tell us which browser you are experiencing the problem on? Also, do the following:

1. Add a complete and valid doctype to your page.
2. Add type attribute to your link to stylesheet.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top