The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Is it possible to change a style based on browser?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #154170

    I need to style something different for IE ONLY. Is it possible to do this? A browser query of sorts?

    I tried prefixing the property in quetion with -ms- but I don’t think it’s prefixable because it’s something so common. I actually tried this:

    -ms-display: none;

    So the broken item would just be hidden and wouldn’t look bad.

    Or… should I just say screw IE users and live life on the bleeding edge?


    Most sites built these days have an IE class built right into the HTML element using some IE conditional code.

    This should come right after your doctype and before the opening <head>:

    <!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
    <!--[if IE 7]><html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
    <!--[if IE 8]><html class="no-js lt-ie9" lang="en"> <![endif]-->
    <!--[if IE 9 ]><html class="ie9 lt-ie10 no-js"> <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js"> <!--<![endif]-->

    If you aren’t using Modernizr (or something similar) you can remove the no-js class right away.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.