Monday, October 8, 2012

CSS Hacks for Internet Explorer

Here's are the samples of CSS Hack for Internet Explorer from IE6 to IE9 version.

body {
   background: #ff0000; /* for all browser */
   background: #0000ff\9/* for IE9 & below */
   background: #00cc00\0//* for IE8 */
   background: *#ff9900; /* for IE7 */
   background: _#ff66ff; /* for IE6 */
}

Internet Explorer 9 & below

The key to targeting Internet Explorer 9 and below, with a hack is to append "\9" (backslash + nine) to end of your style, For example: (see the yellow marker below)

body {
   background: #ff0000; /* for all browser - display "red" */
   background: #0000ff\9/* for IE9 - display "blue" */
}

Internet Explorer 8 & below

The key to targeting Internet Explorer 8 and below, with a hack is to append "\0/" (backslash + zero + slash) to end of your style, For example: (see the yellow marker below)

body {
   background: #ff0000; /* for all browser - display "red" */
   background: #00cc00\0//* for IE8 - display "green" */
}

Internet Explorer 7 & below

The key to targeting Internet Explorer 7 and below, just add "*" (asterisk) at the beginning of your style, For example: (see the yellow marker below)

body {
   background: #ff0000; /* for all browser - display "red" */
   background: *#ff9900; /* for IE7 - display "orange" */
}

Internet Explorer 6 & below

The key to targeting Internet Explorer 6 and below, just add "_" (underscore) at the beginning of your style, For example: (see the yellow marker below)

body {
   background: #ff0000; /* for all browser - display "red" */
   background: _#ff66ff; /* for IE6 - display "pink" */
}

No comments:

Post a Comment