CSS Conditional comments

March 15th, 2009

Hi i am working hard in one new project but the first part of this project have nothing interesting using Flash – haaaaaaaa fuc** – and i expend so much time using and programming Actionscript and when i turn back to my begin, the XHTML, have some problems and one os this problems was using the drunk browser: Internet Explorer.

I think that nobody love IE, but if have one whatever. The fact is that IE is a most problem when use XHTML and it is one of thing that made me a Flash Programmer and not a XHTML Designer professional – hehehe.

Well, CSS and XHTML can work fine into Google Chrome, Mozilla Firefox, Opera, Safari but when you try test your project into the drunk browser you will see the problems:

• Wrong element position
• Wrong font-size
• Wrong list style, background position and so much more wrong things.

To resolve this problem, the first thing that you need is install Firefox, Safari, Opera or Chrome, ehehe, but if your client use Internet Explorer yet, well you will need make a custom style for your site: one work fine for all browser and one single for only resolve the problems of Internet Explorer.

In this case you will import one *.css file for all browsers and use the conditional comment to import a custom style for the Internet Explorer users. Hmmmm great no? To do it you need put this code into <head> tag:

<!--[if IE]><link to your custom style for IE<![endif]-->

You will see in your Dreamweaver, Aptana or other editor that your code will be commented but when you load the page on IE browser this *.css will be loaded and resolver your style problems, the problem is make the style two times but for XHTML sites is necessary.

You can too load files for especificly IE version using others codes like

<!--[if IE 5]>, <!--[if IE 5.5]>, <!--[if lte IE 5.5]>

and others, you can read more about it in bellow link.
http://www.quirksmode.org/css/condcom.html

Read too:

8 Responses to “CSS Conditional comments”

  1. » CSS Conditional comments | DES 84 - Blog of DES84 Website | Best Web Gallery Says:

    [...] » CSS Conditional comments | DES 84 – Blog of DES84 Website [...]

  2. uwiuw Says:

    wow thanks i think i need such tips. thanks

  3. Pablo Davi Says:

    @uwiuw: Really its a great solution.

  4. How to Get Six Pack Fast Says:

    Hey, nice tips. I’ll buy a glass of beer to that man from that forum who told me to visit your blog :)

  5. Pablo Davi Says:

    Buy me a beer too. ehHEhe thanks and continue reading the blog
    : )

  6. » Another IE (now 7) Hack | DES 84 - Blog of DES84 Website Says:

    [...] to make other CSS file and import it with conditional only for IE like show my post about the CSS Conditional Comments, but searching and reading one more i saw one article that resolve my problem, use an IE7 Hack, [...]

  7. Peyton Mitchellson Says:

    Useful views and useful contribution. I really enjoy piano a lot. I’ve marked it to revisit later. Imagination is more important than knowledge-Einstein

  8. the vampire diaries tv show Says:

    This article is immensely informative and fruitful.It will help readers to take proactive decisions and update themselves accordingly. Thanks a lot for providing so valuable facts.

Leave a Reply