How to Print it? Only Text | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11

How to Print it? Only Text

I Want Print Only Text or Customized Page, Like a Only Text and Hide Print Button. https://code.sololearn.com/Wx701J6OdVIi/?ref=app

4th Mar 2021, 10:02 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
3 Answers
+ 8
It sounds like you want the print preview and hard copies to show the "Print Only Text" but not have it show in the regular page. You'd want to use CSS's media selector for print and screen. Add this to your CSS tab: h1 { display: none; } @media print { h1 { display: block; /* show the "Print Only Text" in print media. */ } input[type="button"] { display: none; /* hide the Print button in print media. */ } }
4th Mar 2021, 10:18 PM
Josh Greig
Josh Greig - avatar
+ 5
Ayesha wrote, "Why you hide <h1> tage ?" Response: I used CSS to hide it because it said "ONLY PRINT THIS TEXT". I interpretted that as make that text exclusive to printing and hidden to all other media. If you wanted it shown whether the page is being printed or not, just remove all my references to h1. In other words, this would be the only CSS you should use: @media print { input[type="button"] { display: none; /* hide the Print button in print media. */ } }
5th Mar 2021, 12:04 AM
Josh Greig
Josh Greig - avatar
+ 3
Why you hide <h1> tage ?
4th Mar 2021, 10:33 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar