Skip to content

Instantly share code, notes, and snippets.

@yakubu234
Created December 31, 2019 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yakubu234/ad414d2f09a72d30707c232d48e18a9e to your computer and use it in GitHub Desktop.
Save yakubu234/ad414d2f09a72d30707c232d48e18a9e to your computer and use it in GitHub Desktop.
<html>
<head>
<title>a gist by yakubu abiola on html print part page </title>
<style media="screen">
.noPrint{ display: block; }
.yesPrint{ display: block !important; }
</style>
<style media="print">
.noPrint{ display: none; }
.yesPrint{ display: block !important; }
</style>
</head>
<body>
<div>
<p>this part here will not be printed </p>
<!-- this part above will not be printed -->
<div class= "yesPrint">
<!-- the entire data in this div will be printed -->
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
</div>
<-- the print ends here -->
<!-- the button to print will be here immediately after the div to be printed , so as not to print the button along with it -->
<input TYPE="button" onClick="window.print()">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment