Monday, March 17, 2014

CSS Validations

Validation is checking something against a rule. When you are beginners, this is very common that you will do many mistakes in writing your CSS rules. How you will make sure whatever you have written is 100% accurate and upto the W3 quality standards.
If you use CSS your code needs to be correct. Improper code may cause unexpected results in how your page looks or functions.
But if you want to validate your CSS style sheet embedded in an (X)HTML document, you should first check that the (X)HTML you use is valid.
Tool to check the validity of (X)HTML document: Validate (X)HTML document.
There are following good tools to check the validity of your CSS.
W3 CSS Validator
W3C CSS Validator (World Wide Web Consortium)   This validator checks your css by either file upload, direct input, or using URI - one page at a time. This validator helps you to locate all the errors in your CSS.
WDG - CSS validator
The WDG CSS check validator lets you validate your css by direct input, file upload, and using URI. Errors will be listed by line and column numbers if you have any. errors usually come with links to explain the reason of error.
A CSS validator checks your Cascading Style Sheets to make sure that they comply with the CSS standards set by the W3 Consortium. There are a few validators which will also tell you which CSS features are supported by which browsers (since not all browsers are equal in their CSS implementation).

Why Validate Your HTML Code?

There are a number of reasons why you should validate your code. But major ones are:
  • It Helps Cross-Browser, Cross-Platform and Future Compatibility.
  • Increase Search Engine Visibility because you have good quality website.
  • Professionalism: As a web developer your code should not raise errors while seen by the visitors.

CSS Layouts

Hope you are very comfortable with HTML tables and you are efficient in designing page layouts using HTML Tables. But you know CSS also provides plenty of controls for positioning elements in a document. Since CSS is the wave of the future, why not learn and use CSS instead of tables for page layout purposes?
I'm listing down few pros and cons of both the technologies:
  • Most browsers support tables, while CSS support is being slowly adopted.
  • Tables are more forgiving when the browser window size changes - morphing their content and wrapping to accommodate the changes accordingly. CSS positioning tends to be exact and fairly inflexible.
  • Tables are much easier to learn and manipulate than CSS rules.
But each of these arguments can be reversed:
  • CSS is pivotal to the future of Web documents and will be supported by most browsers Using it now helps guarantee future compliance.
  • CSS is more exact than tables, allowing your document to be viewed as you intended, regardless of the browser window.
  • Keeping track of nested tables can be a real pain.CSS rules tend to be well organized, easily read, and easily changed.
Finally, I would suggest you to use whichever technology makes sense to you - use what you know or what presents your documents in the best way.
CSS also provides table-layout property to make your tables load much faster.Following is the example:
<table style="table-layout:fixed;width:600px;">
  <tr height="30">
    <td width="150">CSS table layout cell 1</td>
    <td width="200">CSS table layout cell 2</td>
    <td width="250">CSS table layout cell 3</td>
  </tr>
</table>
You will notice the benefits more on large tables. The reason this makes tables load faster is because with traditional HTML, the browser had to calculate every cell before finally rendering the table. When you set the table-layout algorithm to fixed however, it only needs to look at the first row before rendering the whole table. This means that your table will need to have fixed column widths and row heights.

Sample Column Layout:

Here are the steps to create a simple Column Layout using CSS:
Set the margin and padding of the complete document as follows:
<style tyle="text/css">
<!--
body {
    margin:9px 9px 0 9px;
    padding:0;
    background:#FFF;
}
-->
</style>
Now we will define a column with yellow color and later we will attach this rule to a <div>:
<style tyle="text/css">
<!--
#level0 {
     background:#FC0;
}
-->
</style>
Upto this point we will have a document with yellow body, so lets now define another division inside level0:
<style tyle="text/css">
<!--
#level1 {
    margin-left:143px;
    padding-left:9px;
    background:#FFF;
}
-->
</style>
Now we will nest one more division inside level1 and we will change just background color:
<style tyle="text/css">
<!--
#level2 {
    background:#FFF3AC;
}
-->
</style>
Finally we use the same technique, nest a level3 division inside level2 to get the visual layout for the right column:
<style tyle="text/css">
<!--
#level3 {
    margin-right:143px;
    padding-right:9px;
    background:#FFF;
}
#main {
    background:#CCC;
}
-->
</style>
Complete source code:
<style tyle="text/css">
<!--
body {
    margin:9px 9px 0 9px;
    padding:0;
    background:#FFF;}
  #level0 {
    background:#FC0;}
  #level1 {
    margin-left:143px;
    padding-left:9px;
    background:#FFF;}
  #level2 {
    background:#FFF3AC;}
  #level3 {
    margin-right:143px;
    padding-right:9px;
    background:#FFF;}
  #main {
    background:#CCC;}
-->
</style>
<body>
  <div id="level0">
    <div id="level1">
      <div id="level2">
        <div id="level3">
          <div id="main">
            Final Content goes here...
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
Similar way you can add top navigation bar or ad bar at the top of the page.

CSS Printing - @media Rule

You can use CSS to change the appearance of your web page when it's printed on a paper. You can specify one font for the screen version and another for the print version.
You have seen @media rule in previous chapters. This rule allows you to specify different style for different media. So you can define different rules for screen and a printer.
The example below specifies different font families for screen and print. Next CSS uses the same font size for both screen as well as printer.
<style tyle="text/css">
<!--
@media screen
{
p.bodyText {font-family:verdana, arial, sans-serif;}
}

@media print
{
p.bodyText {font-family:georgia, times, serif;}
}
@media screen, print
{
p.bodyText {font-size:10pt}
}
-->
</style>
If you are defining your style sheet in a separate file then you can also use the media attribute when linking to an external style sheet:
<link rel="stylesheet" type="text/css"
  media="print" href="mystyle.css">

CSS - Aural Media

A web document can be rendered by a speech synthesizer. CSS2 allows you to attach specific sound style features to specific document elements.
Aural rendering of documents is mainly used by the visually impaired. Some of the situations in which a document can be accessed by means of aural rendering rather than visual rendering are the following.
  • Learning to read
  • Training
  • Web access in vehicles
  • Home entertainment
  • Industrial documentation
  • Medical documentation
When using aural properties, the canvas consists of a three-dimensional physical space (sound surrounds) and a temporal space (one may specify sounds before, during, and after other sounds).
The CSS properties also allow you to vary the quality of synthesized speech (voice type, frequency, inflection, etc.)
Here is one example:
<style tyle="text/css">
<!--
h1, h2, h3, h4, h5, h6 {
    voice-family: paul;
    stress: 20;
    richness: 90;
    cue-before: url("ping.au")
}
p.heidi { azimuth: center-left }
p.peter { azimuth: right }
-->
</style>
This will direct the speech synthesizer to speak headers in a voice (a kind of audio font) called "paul", on a flat tone, but in a very rich voice. Before speaking the headers, a sound sample will be played from the given URL.
Paragraphs with class heidi will appear to come from front left (if the sound system is capable of spatial audio), and paragraphs of class peter from the right.
Now we will see various properties related to aural media.
  • The azimuth property sets where the sound should come from horizontally.
  • The elevation property sets where the sound should come from vertically.
  • The cue-after specifies a sound to be played after speaking an element's content to delimit it from other.
  • The cue-before specifies a sound to be played before speaking an element's content to delimit it from other.
  • The cue is a shorthand for setting cue-before and cue-after
  • The pause-after specifies a pause to be observed after speaking an element's content.
  • The pause-before specifies a pause to be observed before speaking an element's content.
  • The pause is a shorthand for setting pause-before and pause-after.
  • The pitch specifies the average pitch (a frequency) of the speaking voice.
  • The pitch-range specifies variation in average pitch.
  • The play-during specifies a sound to be played as a background while an element's content is spoken.
  • The richness specifies the richness, or brightness, of the speaking voice.
  • The speak specifies whether text will be rendered aurally and if so, in what manner.
  • The speak-numeral controls how numerals are spoken.
  • The speak-punctuation specifies how punctuation is spoken.
  • The speech-rate specifies the speaking rate.
  • The stress specifies the height of "local peaks" in the intonation contour of a voice.
  • The voice-family specifies prioritized list of voice family names.
  • The volume refers to the median volume of the voice.

The azimuth property:

This property sets where the sound should come from horizontally. The possible values are:
  • angle: Position is described in terms of an angle within the range -360deg to 360deg. The value 0deg means directly ahead in the center of the sound stage. 90deg is to the right, 180deg behind, and 270deg (or, equivalently and more conveniently, -90deg) to the left.
  • left-side: Same as '270deg'. With 'behind', '270deg'.
  • far-left: Same as '300deg'. With 'behind', '240deg'.
  • left: Same as '320deg'. With 'behind', '220deg'.
  • center-left: Same as '340deg'. With 'behind', '200deg'.
  • center: Same as '0deg'. With 'behind', '180deg'.
  • center-right: Same as '20deg'. With 'behind', '160deg'.
  • right: Same as '40deg'. With 'behind', '140deg'.
  • far-right: Same as '60deg'. With 'behind', '120deg'.
  • right-side: Same as '90deg'. With 'behind', '90deg'.
  • leftwards: Moves the sound to the left and relative to the current angle. More precisely, subtracts 20 degrees.
  • rightwards: Moves the sound to the right, relative to the current angle. More precisely, adds 20 degrees.
Here is one example:
<style tyle="text/css">
<!--
h1   { azimuth: 30deg }
td.a { azimuth: far-right }          /*  60deg */
#12  { azimuth: behind far-right }   /* 120deg */
p.comment { azimuth: behind }        /* 180deg */
-->
</style>

The elevation property:

This property sets where the sound should come from vertically. The possible values are:
  • angle: Specifies the elevation as an angle, between -90deg and 90deg. 0deg means on the forward horizon, which loosely means level with the listener. 90deg means directly overhead and -90deg means directly below.
  • below: Same as '-90deg'.
  • level: Same as '0deg'.
  • above: Same as '90deg'.
  • higher: Adds 10 degrees to the current elevation.
  • lower: Subtracts 10 degrees from the current elevation.
Here is one example:
<style tyle="text/css">
<!--
h1   { elevation: above }
tr.a { elevation: 60deg }
tr.b { elevation: 30deg }
tr.c { elevation: level }
-->
</style>

The cue-after property:

This property specifies a sound to be played after speaking an element's content to delimit it from other. The possible values are:
  • url: The URL of a sound file to be played.
  • none: Nothing has to be played
Here is one example:
<style tyle="text/css">
<!--
a {cue-after: url("dong.wav");}
h1 {cue-after: url("pop.au"); }
-->
</style>

The cue-before property:

This property specifies a sound to be played before speaking an element's content to delimit it from other. The possible values are:
  • url: The URL of a sound file to be played.
  • none: Nothing has to be played
Here is one example:
<style tyle="text/css">
<!--
a {cue-before: url("bell.aiff");}
h1 {cue-before: url("pop.au"); }
-->
</style>

The cue property:

This property is a shorthand for setting cue-before and cue-after. If two values are given, the first value is cue-before and the second is cue-after. If only one value is given, it applies to both properties.
For example the following two rules are equivalent:
<style tyle="text/css">
<!--
h1 {cue-before: url("pop.au"); cue-after: url("pop.au") }
h1 {cue: url("pop.au") }
-->
</style>

The pause-after property:

This property specifies a pause to be observed after speaking an element's content. The possible values are:
  • time: Expresses the pause in absolute time units (seconds and milliseconds).
  • percentage: Refers to the inverse of the value of the speech-rate property. For example, if the speech-rate is 120 words per minute (i.e. a word takes half a second, or 500ms) then a pause-after of 100% means a pause of 500 ms and a pause-after of 20% means 100ms.

The pause-before property:

This property specifies a pause to be observed before speaking an element's content. The possible values are:
  • time: Expresses the pause in absolute time units (seconds and milliseconds).
  • percentage: Refers to the inverse of the value of the speech-rate property. For example, if the speech-rate is 120 words per minute (i.e. a word takes half a second, or 500ms) then a pause-before of 100% means a pause of 500 ms and a pause-before of 20% means 100ms.

The pause property:

This property is a shorthand for setting pause-before and pause-after. If two values are given, the first value is pause-before and the second is pause-after.
Here is the example:
<style tyle="text/css">
<!--
/* pause-before: 20ms; pause-after: 20ms */
h1 { pause : 20ms }  
/* pause-before: 30ms; pause-after: 40ms */
h2{ pause : 30ms 40ms }  
/* pause-before: ?; pause-after: 10ms */
h3 { pause-after : 10ms }
-->
</style>

The pitch property:

This property specifies the average pitch (a frequency) of the speaking voice. The average pitch of a voice depends on the voice family. For example, the average pitch for a standard male voice is around 120Hz, but for a female voice, it's around 210Hz. The possible values are:
  • frequency: Specifies the average pitch of the speaking voice in hertz (Hz).
  • x-low, low, medium, high, x-high : These values do not map to absolute frequencies since these values depend on the voice family.

The pitch-range property:

This property specifies variation in average pitch. The possible values are:
  • number: A value between '0' and '100'. A pitch range of '0' produces a flat, monotonic voice. A pitch range of 50 produces normal inflection. Pitch ranges greater than 50 produce animated voices.

The play-during property:

This property specifies a sound to be played as a background while an element's content is spoken. Possible values could be any of the followings:
  • URI: The sound designated by this <uri> is played as a background while the element's content is spoken.
  • mix: When present, this keyword means that the sound inherited from the parent element's play-during property continues to play and the sound designated by the uri is mixed with it. If mix is not specified, the element's background sound replaces the parent's.
  • repeat: When present, this keyword means that the sound will repeat if it is too short to fill the entire duration of the element. Otherwise, the sound plays once and then stops.
  • auto: The sound of the parent element continues to play.
  • none: This keyword means that there is silence.
Here is the example:
<style tyle="text/css">
<!--
blockquote.sad { play-during: url("violins.aiff") }
blockquote q   { play-during: url("harp.wav") mix }
span.quiet     { play-during: none }
-->
</style>

The richness property:

This property specifies the richness, or brightness, of the speaking voice. The possible values are:
  • number: A value between '0' and '100'. The higher the value, the more the voice will carry. A lower value will produce a soft, mellifluous voice.

The speak property:

This property specifies whether text will be rendered aurally and if so, in what manner. The possible values are:
  • none: Suppresses aural rendering so that the element requires no time to render.
  • normal: Uses language-dependent pronunciation rules for rendering an element and its children.
  • spell-out: Spells the text one letter at a time .
Note the difference between an element whose 'volume' property has a value of 'silent' and an element whose 'speak' property has the value 'none'. The former takes up the same time as if it had been spoken, including any pause before and after the element, but no sound is generated. The latter requires no time and is not rendered

The speak-numeral property:

This property controls how numerals are spoken. The possible values are:
  • digits: Speak the numeral as individual digits. Thus, "237" is spoken "Two Three Seven".
  • continuous: Speak the numeral as a full number. Thus, "237" is spoken "Two hundred thirty seven". Word representations are language-dependent.

The speak-punctuation property:

This property specifies how punctuation is spoken. The possible values are:
  • code: Punctuation such as semicolons, braces, and so on are to be spoken literally.
  • none: Punctuation is not to be spoken, but instead rendered naturally as various pauses.

The speech-rate property:

This property specifies the speaking rate. Note that both absolute and relative keyword values are allowed. The possible values are:
  • number: Specifies the speaking rate in words per minute.
  • x-slow: Same as 80 words per minute..
  • slow: Same as 120 words per minute .
  • medium: Same as 180 - 200 words per minute.
  • fast: Same as 300 words per minute.
  • x-fast: Same as 500 words per minute.
  • faster: Adds 40 words per minute to the current speech rate.
  • slower: Subtracts 40 words per minutes from the current speech rate.

The stress property:

This property specifies the height of "local peaks" in the intonation contour of a voice. English is a stressed language, and different parts of a sentence are assigned primary, secondary, or tertiary stress. The possible values are:
  • number: A value, between '0' and '100'. The meaning of values depends on the language being spoken. For example, a level of '50' for a standard, English-speaking male voice (average pitch = 122Hz), speaking with normal intonation and emphasis would have a different meaning than '50' for an Italian voice.

The voice-family property:

The value is a comma-separated, prioritized list of voice family names. It can have following values:
  • generic-voice : Values are voice families. Possible values are 'male', 'female', and 'child'.
  • specific-voice: Values are specific instances (e.g., comedian, trinoids, carlos, lani).
Here is the example:
<style tyle="text/css">
<!--
h1 { voice-family: announcer, male }
p.part.romeo  { voice-family: romeo, male }
p.part.juliet { voice-family: juliet, female }
-->
</style>

The volume property:

Volume refers to the median volume of the voice. It can have following values:
  • numbers: Any number between '0' and '100'. '0' represents the minimum audible volume level and 100 corresponds to the maximum comfortable level.
  • percentage: These values are calculated relative to the inherited value, and are then clipped to the range '0' to '100'.
  • silent: No sound at all. The value '0' does not mean the same as 'silent'.
  • x-soft: Same as '0'.
  • soft: Same as '25'.
  • medium: Same as '50'.
  • loud: Same as '75'.
  • x-loud: Same as '100'.
Here is the example:
<style tyle="text/css">
<!--
P.goat  { volume: x-soft }
-->
</style>
Paragraphs with class goat will be very soft.

CSS Paged Media - @page Rule

Paged media differ from continuous media in that the content of the document is split into one or more discrete pages. Paged media includes paper, transparencies, pages that are displayed on computer screens, etc.
The CSS2 standard introduces some basic pagination control features that let authors help the browser figure out how to best print their documents.
The CSS2 page model specifies how a document is formatted within a rectangular area -- the page box -- that has a finite width and height. These features fall into two groups:
  • CSS2 features that define a particular page layout.
  • CSS2 features that control the pagination of a document.

Defining Pages: the @page rule

The CSS2 defines a "page box", a box of finite dimensions in which content is rendered. The page box is a rectangular region that contains two areas:
  • The page area: The page area includes the boxes laid out on that page. The edges of the page area act as the initial containing block for layout that occurs between page breaks.
  • The margin area: which surrounds the page area.
You can specify the dimensions, orientation, margins, etc. of a page box within an @page rule. The dimensions of the page box are set with the 'size' property. The dimensions of the page area are the dimensions of the page box minus the margin area.
For example, the following @page rule sets the page box size to 8.5 x 11 inches and creates '2cm' margin on all sides between the page box edge and the page area:
<style tyle="text/css">
<!--
@page { size:8.5in 11in; margin: 2cm }
-->
</style>
You can use the margin, margin-top, margin-bottom, margin-left, and margin-right properties within the @page rule to set margins for your page.
Finally, the marks property is used within the @page rule to create crop and registration marks outside the page box on the target sheet. By default, no marks are printed. You may use one or both of the crop and cross keywords to create crop marks and registration marks, respectively, on the target print page.

Setting Page Size:

The size property specifies the size and orientation of a page box. There are four values which can be used for page size:
  • auto: The page box will be set to the size and orientation of the target sheet.
  • landscape: Overrides the target's orientation. The page box is the same size as the target, and the longer sides are horizontal.
  • portrait: Overrides the target's orientation. The page box is the same size as the target, and the shorter sides are horizontal.
  • length: Length values for the 'size' property create an absolute page box. If only one length value is specified, it sets both the width and height of the page box. Percentage values are not allowed for the 'size' property.
In the following example, the outer edges of the page box will align with the target. The percentage value on the 'margin' property is relative to the target size so if the target sheet dimensions are 21.0cm x 29.7cm (i.e., A4), the margins are 2.10cm and 2.97cm.
<style tyle="text/css">
<!--
@page {
  size: auto;   /* auto is the initial value */
  margin: 10%;
}
-->
</style>
Below example sets the width of the page box to be 8.5in and the height to be 11in. The page box in this example requires a target sheet size of 8.5"x11" or larger.
<style tyle="text/css">
<!--
@page {
  size: 8.5in 11in;  /* width height */
}
-->
</style>
Once you create a named page layout, you can use it in your document by adding the page property to a style that is later applied to an element in your document. For example, this style renders all the tables in your document on landscape pages:
<style tyle="text/css">
<!--
@page { size : portrait }
@page rotated { size : landscape }
table { page : rotated }
-->
</style>
Due to the above rule, while printing, if the browser encounters a <table> element in your document and the current page layout is the default portrait layout, it starts a new page and prints the table on a landscape page.

Left, right, and first pages:

When printing double-sided documents, the page boxes on left and right pages should be different. This can be expressed through two CSS pseudo-classes as follows:
<style tyle="text/css">
<!--
@page :left {
  margin-left: 4cm;
  margin-right: 3cm;
}

@page :right {
  margin-left: 3cm;
  margin-right: 4cm;
}
-->
</style>
You can specify the style for the first page of a document with the :first pseudo-class:
<style tyle="text/css">
<!--
@page { margin: 2cm } /* All margins set to 2cm */

@page :first {
  margin-top: 10cm    /* Top margin on first page 10cm */
}
-->
</style>

Controlling pagination:

Unless you specify otherwise, page breaks occur only when the page format changes or when the content overflows the current page box. To otherwise force or suppress page breaks, use the page-break-before, pagebreak-after, and page-break-inside properties.
Both the page-break-before and page-break-after properties accept the auto, always, avoid, left, and right keywords.
The keyword auto is the default, it lets the browser generate page breaks as needed. The keyword always forces a page break before or after the element, while avoid suppresses a page break immediately before or after the element. The left and right keywords force one or two page breaks, so that the element is rendered on a left-hand or right-hand page.
Using pagination properties is straightforward. Suppose your document has level-1 headers start new chapters, with sections denoted by level-2 headers. You'd like each chapter to start on a new, right-hand page, but you don't want section headers to be split across a page break from the subsequent content. You can achieve this using following rule:
<style tyle="text/css">
<!--
h1 { page-break-before : right }
h2 { page-break-after : avoid }
-->
</style>
Use only the auto and avoid values with the page-break-inside property. If you prefer that your tables not be broken across pages if possible, you would write the rule:
<style tyle="text/css">
<!--
table { page-break-inside : avoid }
-->
</style>

Controlling widows and orphans:

In typographic lingo, orphans are those lines of a paragraph stranded at the bottom of a page due to a page break, while widows are those lines remaining at the top of a page following a page break. Generally, printed pages do not look attractive with single lines of text stranded at the top or bottom. Most printers try to leave at least two or more lines of text at the top or bottom of each page.
  • The orphans property specifies the minimum number of lines of a paragraph that must be left at the bottom of a page.
  • The widows property specifies the minimum number of lines of a paragraph that must be left at the top of a page.
Here is the example to create 4 lines at the bottom and 3 lines at the top of each page:
<style tyle="text/css">
<!--
@page{orphans:4; widows:2;}
-->
</style>

CSS - Media Types

One of the most important features of style sheets is that they specify how a document is to be presented on different media: on the screen, on paper, with a speech synthesizer, with a braille device, etc.
here are currently two ways to specify media dependencies for style sheets:
  • Specify the target medium from a style sheet with the @media or @import at-rules.
  • Specify the target medium within the document language.

The @media rule:

An @media rule specifies the target media types (separated by commas) of a set of rules.
Following is the example:
<style tyle="text/css">
<!--
@media print {
    body { font-size: 10pt }
  }
  @media screen {
    body { font-size: 12pt }
  }
  @media screen, print {
    body { line-height: 1.2 }
  }
-->
</style>

The document language:

In HTML 4.0, the media attribute on the LINK element specifies the target media of an external style sheet:
Following is the example:
<style tyle="text/css">
<!--
<!doctype html public "-//w3c//dtd html 4.0//en">
<html>
   <head>
      <title>link to a target medium</title>
      <link rel="stylesheet" type="text/css" 
   media="print, handheld" href="foo.css">
   </head>
   <body>
      <p>the body...
   </body>
</html>
-->
</style>

Recognized media types:

The names chosen for CSS media types reflect target devices for which the relevant properties make sense. They give a sense of what device the media type is meant to refer to. Following is the list of various media types:
ValueDescription
allSuitable for all devices.
auralIntended for speech synthesizers.
brailleIntended for braille tactile feedback devices.
embossedIntended for paged braille printers.
handheldIntended for handheld devices (typically small screen, monochrome, limited bandwidth).
printIntended for paged, opaque material and for documents viewed on screen in print preview mode. Please consult the section on paged media.
projectionIntended for projected presentations, for example projectors or print to transparencies. Please consult the section on paged media.
screenIntended primarily for color computer screens.
ttyIntended for media using a fixed-pitch character grid, such as teletypes, terminals, or portable devices with limited display capabilities.
tvIntended for television-type devices.
NOTE: Media type names are case-insensitive.

CSS Filters - Text and Image Effects

You can use CSS filters to add special effects to text, images and other aspects of a webpage without using images or other graphics. Filters only work on Internet Explorer 4.0+,. So if you are developing your site for multi browsers then it may not be a good idea to use CSS filters because there is a possibility that it would not give any advantage.
In this tutorial we will see detail of each CSS filter. These filters may not work in your browser.

Alpha Channel

This filter alters the opacity of the object, which makes it blend into the background. Following are the parameters which can be used in this filter:
ParameterDescription
opacityLevel of the opacity. 0 is fully transparent, 100 is fully opaque.
finishopacityLevel of the opacity at the other end of the object.
styleThe shape of the opacity gradient.

0 = uniform
1 = linear
2 = radial
3 = rectangular
startXX coordinate for opacity gradient to begin.
startYY coordinate for opacity gradient to begin.
finishXX coordinate for opacity gradient to end.
finishYY coordinate for opacity gradient to end.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Alpha(Opacity=100, FinishOpacity=0, Style=2, StartX=20, StartY=40, FinishX=0, FinishY=0)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: blue; Filter: Alpha(Opacity=100, FinishOpacity=0, Style=1, StartX=0, StartY=0, FinishX=580, FinishY=0)">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Motion Blur

This will be used to create blurred pictures or text with the direction and strength. Following are the parameters which can be used in this filter:
ParameterDescription
addTrue or false. If true the image is added to the blurred image and if false the image is not added to the blurred image.
directionThe direction of the blur, going clockwise, rounded to 45-degree increments. The default value is 270 (left).

0 = Top
45 = Top right
90 = Right
135 = Bottom right
180 = Bottom
225 = Bottom left
270 = Left
315 = Top left
strengthThe number of pixels the blur will extend. The default is 5 pixels.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Blur(Add = 0, Direction = 225, Strength = 10)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: blue; Filter: Blur(Add = 1, Direction = 225, Strength = 10)">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Chroma Filter

This will be used to make any particular color transparent and usually it is used with images. You can use it with scrollbars also.Following are the parameters which can be used in this filter:
ParameterDescription
color The color that you'd like to be transparent.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Chroma(Color = #FFFFFF)">

<p>Text Example:</p>
<div style="width: 580; height: 50; font-size: 30pt; font-family: Arial Black; color: #3300FF; Filter: Chroma(Color = #3300FF)">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Drop Shadow Effect

This will be used to create a shadow of your object at the specified X (horizontal) and Y (vertical) offset and color. . Following are the parameters which can be used in this filter:
ParameterDescription
color The color, in #RRGGBB format, of the dropshadow.
offX Number of pixels the drop shadow is offset from the visual object, along the x-axis. Positive integers move the drop shadow to the right, negative integers move the drop shadow to the left.
offY Number of pixels the drop shadow is offset from the visual object, along the y-axis. Positive integers move the drop shadow down, negative integers move the drop shadow up.
positiveIf true, all opaque pixels of the object have a dropshadow. If false, all transparent pixels have a dropshadow. The default is true.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Chroma(Color = #000000) DropShadow(Color=#FF0000, OffX=2, OffY=2, Positive=1)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: DropShadow(Color=#000000, OffX=2, OffY=2, Positive=1)">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Flip Effect

This will be used to create a mirror image of the object. Following are the parameters which can be used in this filter:
ParameterDescription
FlipH Creates a horizontal mirror image
FlipV Creates a vertical mirror image

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: FlipH">

<img src="/images/css.gif" alt="CSS Logo" style="Filter: FlipV">

<p>Text Example:</p>
<div style="width: 300; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: FlipV">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

CSS Logo

Text Example:
CSS Tutorials

Glow Effect

This will be used to create a glow around the object. If it is a transparent image then glow is created around the opaque pixels of it. Following are the parameters which can be used in this filter:
ParameterDescription
color The color you want the glow to be.
strengthThe intensity of the glow (from 1 to 255).

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Chroma(Color = #000000) Glow(Color=#00FF00, Strength=20)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Glow(Color=#00FF00, Strength=20)">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Grayscale Effect

This will be used to convert the colors of the object to 256 shades of gray. Following are the parameters which can be used in this filter:
ParameterDescription
gray Converts the colors of the object to 256 shades of gray.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Gray">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Gray">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Invert Effect

This will be used to map the colors of the object to their opposite value in the color spectrum ie. to create a negative image. Following are the parameters which can be used in this filter:
ParameterDescription
InvertMaps the colors of the object to their opposite value in the color spectrum.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: invert">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: invert">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Mask Effect

This will be used to turn transparent pixels to a specified color and makes opaque pixels transparent. Following are the parameters which can be used in this filter:
ParameterDescription
color The color that the transparent areas will become.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="FILTER: Chroma(Color = #000000) Mask(Color=#00FF00)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Mask(Color=#00FF00)">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Shadow Filter

This will be used to create an attenuated shadow in the direction and color specified. This is a filter lies in between Dropshadow and a Glow. Following are the parameters which can be used in this filter:
ParameterDescription
color The color that you want the shadow to be.
directionThe direction of the blur, going clockwise, rounded to 45-degree increments. The default value is 270 (left).

0 = Top
45 = Top right
90 = Right
135 = Bottom right
180 = Bottom
225 = Bottom left
270 = Left
315 = Top left

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="FILTER: Chroma(Color = #000000) Shadow(Color=#00FF00, Direction=225)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Shadow(Color=#0000FF, Direction=225)">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

Wave Effect

This will be used to gives the object a sine wave distortion to make it look wavey. Following are the parameters which can be used in this filter:
ParameterDescription
addA value of 1 adds the original image to the waved image, 0 does not.
freq The number of waves.
lightThe strength of the light on the wave (from 0 to 100).
phase At what degree the sine wave should start (from 0 to 100).
strength The intensity of the wave effect.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="FILTER: Chroma(Color = #000000) Wave(Add=0, Freq=1, LightStrength=10, Phase=220, Strength=10)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Wave(Add=0, Freq=1, LightStrength=10, Phase=20, Strength=20)">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials

X-Ray Effect

This will be used to grayscales and flattens the color depth. Following are the parameters which can be used in this filter:
ParameterDescription
xrayGrayscales and flattens the color depth.

Example:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Xray"">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; style="Filter: Xray">CSS Tutorials</div>
This will produce following result:
Image Example:
CSS Logo

Text Example:
CSS Tutorials