Skip to content

Instantly share code, notes, and snippets.

@sudikrt
Created August 2, 2017 18:08
Show Gist options
  • Save sudikrt/9e7ee343738958044c1bdaefce252524 to your computer and use it in GitHub Desktop.
Save sudikrt/9e7ee343738958044c1bdaefce252524 to your computer and use it in GitHub Desktop.
HTML to print section CSS
<html>
<head>
<style>
@media print {
body * {
visibility: hidden;
}
#section-to-print, #section-to-print * {
visibility: visible;
}
}
</style>
<script>
function myFunction() {
window.print();
}
</script>
</head>
<body>
<h1 id="section-to-print"> This is test Text in the worls</h1>
<br/>
<h1> This is test Text in the worls 1</h1>
<br/>
<h1 id="section-to-print"> This is test Text in the worls 2</h1> <br/>
<h1> This is test Text in the worls 3</h1> <br/>
<h1 id="section-to-print"> This is test Text in the worls 4</h1> <br/>
<button onclick="myFunction()">Print this page</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment