Printing a page with CSS

Printing a page with CSS  Print() Method: To get the content of your current window you can use print() method and it also opens the print dialog box for the preferred printing options.

CSS window.print() Syntax

To Print the current page–window.print();

The window.print()  has no parameters and a return value

window.print() Example

<!DOCTYPE html>
<p>Click on the button to print the current page.</p>
<button onclick="myFunction()">Print</button>
function myFunction() {

window.print() Example Output

window.print() Example Output

Now click on the button “Print”

window.print() Example Output 2