IE8 and conditional CSS statement

Discussion in 'CSS' started by oliviershoek-consulting, Mar 16, 2012.

  1. #1
    Hi

    I have this statement in my css

    .tag {
        font-size: 2.25em;
        [if lt IE9] font-size: 1.5em;
    }
    Code (markup):
    But IE 8 ignores this and shows the larger font size, and it does not fit, so it is wraping and there is no space for it to wrap. Looks fine in Firefox and Safari...

    What do you do to make IE8 show the correct (smaller) font size.
     
    oliviershoek-consulting, Mar 16, 2012 IP
  2. czent

    czent Peon

    Messages:
    45
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    0
    #2
    I am not sure about using the [if lt IE9] inside a CSS definition.

    What is normally done is you apply a class to the <html> or <body> element in case of IE9 & below, and use that class to apply your special styling.

    <!--[if lt IE9]><html class="ie"><![endif]-->

    then

    html.ie .tag { font-size: 1.5em; }
     
    czent, Mar 16, 2012 IP
  3. oliviershoek-consulting

    oliviershoek-consulting Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I read about that method too, but this website says you can insert the conditional statements (which are actually javascript) into css files. A lot of people advised against it by commenting on that page, for various reasons, so I will try the other method now.
     
    oliviershoek-consulting, Mar 17, 2012 IP
  4. oliviershoek-consulting

    oliviershoek-consulting Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Id like to replace all content with you need to upgrade your browser (and a link to firefox download page), but I doubt my client would like that. About 40% of visitors are on ie8 on my clients website.
     
    oliviershoek-consulting, Mar 17, 2012 IP