Created
September 27, 2021 16:50
-
-
Save jdanyow/5acc670fbbef67036a4aae99577b033a to your computer and use it in GitHub Desktop.
Printing example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Standard page title</title> | |
<style> | |
@media print { | |
.hidden-print { | |
display: none; | |
} | |
.page-break-before-always { | |
page-break-before: always; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Hello world!</h1> | |
<p>This paragraph will print</p> | |
<p class="hidden-print">This paragraph will not print</p> | |
<p class="page-break-before-always">This paragraph will print on another page</p> | |
<button class="hidden-print" onclick="window.print()">Print this page</button> | |
<script> | |
addEventListener('beforeprint', () => document.title = 'This title was customized for printing'); | |
addEventListener('afterprint', () => document.title = 'This title was customized for printing'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment