User can set the media types in a different ways and which have the different media styles in which some are shown below.
Using External CSS
By using external CSS is the most common way to set the media type which can be specified by using the <link> tag and user can attach the media file by using the
media attribute the syntax below demonstrates the adding external file as shown below.
[code]
<link href="styles/main.css" rel="stylesheet" media="screen">
<!--CSS styles for computer screens -->
<link href="styles/print.css" rel="stylesheet" media="print">
<!--CSS styles for Printers -->
<link href="styles/all-in-one.css" rel="stylesheet" media="screen, print">
<!--CSS styles for both screens and printers -->
[/code]
Media Type using @import Rule
User can link an external the external web page by using the @import rule in which the media type is specified after the file path which is shown below.
[code]
<style>
@import url(styles/screen.css) screen;
@import url(styles/print.css) print;
@import url(styles/all_in_one.css) screen, print, handheld;
</style>
[/code]
Media Type using Embedded Styles
User can applied the media types by using the embedded styles in which the attribute media must be specified in opening of the <style> tag which is shown below.
[code]
<style media="print">
/*Specific CSS rules for the print version of the webpage */
</style>
[/code]
Media Style using the @media rules
In which user can specify the media types by using the @media in an external style sheet or user can also embedded with in <style> element. media type should be specified after the @media rule, and the CSS rule was defined with in the curly braces which is shown below.
[code]
<style>
/*CSS Styles for Screen */
@media screen{
body{
font-family:Verdana, Papyrus, Arial;
background:gold;
font-size:24px;
}
}
/*CSS Styles for Print Version */
@media print{
body{
font-family:Verdana, Papyrus, Arial;
color:#666;
font-size:16px;
}
}
/*CSS Styles for Screen Print and Handheld Devices */
@media screen print handheld{
body{
font-family:Verdana, Papyrus, Arial;
color:#666;
border:5px solid #ccc;
font-size:16px;
}
}
</style>
[/code]
Pseudo class for print CSS
User can print the several pages by given page but user assign separate margins for all web pages using the three pseudo class which are shown below.
- : first
Which target to the web page.
- : left
Which is used to target even number of pages.
- : right
Which is used to target odd number of pages.