Hi,
I want to put condition on my css file. Is it possible?
Is there any way I can make a condition to check the browser & load the css property accordingly?
Pleas help me if it is possible?
Hi,
I want to put condition on my css file. Is it possible?
Is there any way I can make a condition to check the browser & load the css property accordingly?
Pleas help me if it is possible?
Conditional-CSS example
As you have seen above it is possible to put condition in your css. But is really not a recommended. But still if you really need to do so for different web browsers & optimizing your CSS file then you can do so.Code:a.button_active, a.button_unactive { display: inline-block; [if lte Gecko 1.8] display: -moz-inline-stack; [if lte Konq 3.1] float: left; height: 30px; [if IE 5.0] margin-top: -1px; text-decoration: none; outline: none; [if IE] text-decoration: expression(hideFocus='true'); }
if you need more information & compiler for the same please visit the following website.
http://www.conditional-css.com/
Conditional comments only work in Explorer on Windows
They are supported from Explorer 5 onwards, and it is even possible to distinguish between 5.0, 5.5 and 6.0.
Syntax:
Their basic structure is the same as an HTML comment (<!-- -->). Therefore all other browsers will see them as normal comments and will ignore them entirely. Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files.Code:<!--[if IE 6]> Special instructions for IE 6 here <![endif]-->
You can also put an entire new <link> tag in the conditional comment referring to an extra style sheet.
Only IE6+/Windows supports conditional comments. You can not use conditional comments in the css file.
Don't forget to test your conditional CSS on different browsers other than Internet explorer such as Firefox, Opera, Safari, Google chrome etc.
Bookmarks