


Convert XHTML CSS pages to printer pages_HTML/Xhtml_Web page production
In the past, creating a printer-friendly version of a Web page meant designing a separate page with modified layout and formatting so that it would look good when printed. Now, by using structured XHTML and CSS, you can achieve the same effect with far less effort.
From screen display to printing effect
Most web pages are designed to be viewed on a computer screen. However, sometimes users need to print out certain pages, perhaps to keep a long-term record or to use them as convenient offline reference.
The trouble now is that many of the features that make Web pages look eye-catching and colorful on a color computer screen don’t have the same effect on a printed version of a Web page—especially if the printer is black and white. . When downgraded to grayscale printing, color combinations will lose contrast; graphics will look distorted and take too long to print; navigation buttons that play an important role on Web pages will not print properly. There is also no use on the page.
In order to overcome these problems, Web creators often design a printer-friendly version of the page so that visitors will have the desire to print. Printer-friendly versions usually contain the same content as the main Web page, but omit most graphics, background, and navigation elements. The page also converts color into some form to produce an acceptable grayscale image.
CSS solution
One advantage of using structured XHTML markup and CSS formatting to separate content and presentation is that you can easily reformat the content by changing the CSS style. Therefore, creating a printer-friendly page is a matter of linking a different CSS file to the same XHTML page.
You can link both the screen style sheet and the print style sheet into the same XHTML file, so there is no need to create a separate printer-friendly page, just a printer-friendly style sheet. When you include a multimedia type file in the link code, you are telling the browser which CSS rules to follow or ignore for screen output, and which rules to use for print output.
Here is an example of linking to a pair of CSS files:
The following is the quoted content:
If you need to support older browsers, you must stick to the CSS1 media descriptors screen and print. They are mutually exclusive, so browsers ignore print style sheets when generating pages for screen display, and vice versa. Therefore, each style sheet needs to contain the same style selector, but have different rule declarations to generate page styles separately for different output devices.
Simplify CSS
If you are willing to give up taking care of old browser versions and assume that your users are using browsers that support CSS2 (such as IE5 and above or Netscape6 and above) , you can use the new all media descriptor to greatly simplify CSS code.
Here is an example of a link using CSS2 media descriptors:
The following is the quoted content:
These links are almost identical to the previous ones; the difference is that the CSS file contains the styles for the print media.
Styles associated with media="all" in a CSS file can be applied to screen display, print, and all other media, so you can put all the styles you create in this file. The CSS file associated with media="print" alone can be much smaller because the page inherits all styles from all media files, so there is no need to duplicate those styles in the print media files.
The only styles required in the print media CSS file are those that change or add page styles for print output. Generally speaking, this is nothing more than styles that suppress the display of divs containing graphics and navigation content, and replace the width and margin settings of the body tag and main div with settings suitable for printout.
This trick works because all media CSS files and print media CSS files are combined into the same cascading style rules. Therefore, the order in which these CSS files are linked is quite important. All media file links must be placed before the print media file link.
Here are some tips for using print media CSS files:
If you want to disable the display of a div, use display:none instead of visibility:hidden.
Neither points (pt) nor inches (in) are correct units of measurement for screen display, but they are correct units of measurement for printed output.
The selectors you use in print media files should be exactly the same as the selectors you use in all media files. For example, if you use div#sidenav to select the div with id sidenav in all media files, then using #sidenav in the printed media file may not successfully achieve your goal.
Don’t forget to explicitly force override rule declarations that change from one file to another. For example, if you set padding for an element in all media files and want to remove the padding in the print output, it is not enough to add a style that ignores the padding declaration in the print media file - you must set it explicitly padding:0pt to replace the previous setting.
If you are using a graphics editor such as Dreamweaver, you can preview the generated page on screen rather than as a printed output. To preview print styles in Dreamweaver's Design view window, change the link to the print media CSS file to media="screen". This allows you to preview CSS styles in print media files. Don't forget to change the media descriptor back to media="print" before publishing your page.
When you need to provide a printer-friendly web page for your visitors, you no longer need to create a separate version of the original page. Any XHTML/CSS page can be converted into a printer-friendly page by adding a link to a CSS stylesheet with the media="print" media descriptor.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1
Easy-to-use and free code editor

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)