How to disable printing of pages _css/html

Source: Internet
Author: User
Solution Idea:
It is not possible to really prohibit the printing of the page, but if you can set the user to print to the blank, it is to achieve the purpose of banning printing.
Specific steps:
code example:

<style>
@media print{
Body{display:none}
}
</style>
<body>
Main contents of the document
</body>

Note: The CSS defined in the @media print{} rule only takes effect on pages that are printed.
Tip: In many forums in the printing of posts are used a dedicated page to achieve, if you can skillfully use the @media print{} rules, you do not have to do a separate printing page.
Tips:
@media print{} rules can be used for code print, as well as all and screen.
Similar @media rules are shown in table 2.2.1.

Rule description
@import Specifies the imported external style sheet and target media. The rule must first declare in the style sheet header
@charset is used within an external style sheet file. Specifies the character set used by the style sheet.
@font-face to set OpenType fonts for embedded HTML documents (ie5+ support required)
@media Specify a style sheet rule for the specified media type (requires ie5.5+ support)


Special Tips
Run this example code, and then print the page, and the results will not include the document main content.

Special Notes

This example uses the @media rule to define the style that the page applies to when it is printed, and print means that the defined CSS is applied to the printer, and similar print media types are:
All applies to all types of devices
Screen applies to a computer's monitor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.