css conditionals

Discussion in 'HTML' started by Nick Wedd, Mar 18, 2008.

  1. Nick Wedd

    Nick Wedd Guest

    At present, I have some pages which include the lines

    <style type="text/css">
    @import url(../c.css);
    </style>
    <!--[if lt IE 8]>
    <style type="text/css">
    @import url(../ie.css);
    </style>
    <![endif]-->

    so as to get them to render the way I want even with MS's defective
    browser. This works. But it would be less messy if the conditional
    stuff could be done inside my normal stylesheet c.css, instead of in
    every page. Is there a way of achieving this?

    Nick
    --
    Nick Wedd
     
    Nick Wedd, Mar 18, 2008
    #1
    1. Advertising

  2. Nick Wedd wrote:
    > At present, I have some pages which include the lines
    >
    > <style type="text/css">
    > @import url(../c.css);
    > </style>
    > <!--[if lt IE 8]>
    > <style type="text/css">
    > @import url(../ie.css);
    > </style>
    > <![endif]-->
    >
    > so as to get them to render the way I want even with MS's defective
    > browser. This works. But it would be less messy if the conditional
    > stuff could be done inside my normal stylesheet c.css, instead of in
    > every page. Is there a way of achieving this?


    There are hacks that exploit deficiencies in various IE versions to add
    CSS that works only in or fails only in IE or particular versions. But
    none of them is transparent; all require commenting if you expect to
    remember why your code is the way it is the next time you look at it.

    But you can cut out four lines from your code above by using LINK tags
    instead of STYLE tags with the @import rule.

    <link rel="stylesheet" type="text/css" href="../c.css">
    <!--[IF LT ie 8]>
    <link rel="stylesheet" type="text/css" href="../ie.css">
    <![endif]-->
     
    Harlan Messinger, Mar 18, 2008
    #2
    1. Advertising

  3. Nick Wedd

    dorayme Guest

    In article <>,
    Harlan Messinger <> wrote:

    > Nick Wedd wrote:
    > > At present, I have some pages which include the lines
    > >
    > > <style type="text/css">
    > > @import url(../c.css);
    > > </style>
    > > <!--[if lt IE 8]>
    > > <style type="text/css">
    > > @import url(../ie.css);
    > > </style>
    > > <![endif]-->
    > >
    > > so as to get them to render the way I want even with MS's defective
    > > browser. This works. But it would be less messy if the conditional
    > > stuff could be done inside my normal stylesheet c.css, instead of in
    > > every page. Is there a way of achieving this?

    >
    > There are hacks that exploit deficiencies in various IE versions to add
    > CSS that works only in or fails only in IE or particular versions. But
    > none of them is transparent; all require commenting if you expect to
    > remember why your code is the way it is the next time you look at it.
    >
    > But you can cut out four lines from your code above by using LINK tags
    > instead of STYLE tags with the @import rule.
    >
    > <link rel="stylesheet" type="text/css" href="../c.css">
    > <!--[IF LT ie 8]>
    > <link rel="stylesheet" type="text/css" href="../ie.css">
    > <![endif]-->


    And you can go further in reducing the "mess" you described by
    either using your original or Harlan's and putting into an
    "include" - which is usually a short sentence.

    --
    dorayme
     
    dorayme, Mar 18, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. .Net Sports
    Replies:
    15
    Views:
    2,686
    Ted Miller
    Feb 3, 2006
  2. Mustafa Aydin

    Conditionals & paths

    Mustafa Aydin, Apr 21, 2004, in forum: XML
    Replies:
    0
    Views:
    463
    Mustafa Aydin
    Apr 21, 2004
  3. Replies:
    1
    Views:
    1,423
    Zafar Abbas
    Dec 30, 2005
  4. Barney Frank
    Replies:
    3
    Views:
    332
    anton muhin
    Jul 29, 2004
  5. Joshua Ginsberg

    Inline Conditionals?

    Joshua Ginsberg, Aug 24, 2004, in forum: Python
    Replies:
    15
    Views:
    3,868
    Martin Maney
    Sep 6, 2004
Loading...

Share This Page