SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Define separate property value for IE and FF

    Hi

    For browser differences, I want padding-right to be 2px in FF and 4px in IE and I didnt want to use the IE conditional statement to load a separate css file just for this.

    // seems to be treated as a comment in FF.

    Code CSS:
    #id1
     {
            display:block;
            margin-top:1px;
            padding-right:2px;   /* Need FF to have 2px while IE to have 4px */
            //padding-right:4px; /* This will be read by IE but not by FF */
     }
    Is this the only way or is there a better way ?

    Thanks
    Anjanesh

  2. #2
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use star hack

    Code:
     #id1
    {
            display:block;
            margin-top:1px;
            padding-right:2px;   /* Need FF to have 2px while IE to have 4px */
     }
    
    * html #id1
     {
            padding-right:4px; /* This will be read by IE but not by FF */
     }

  3. #3
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That won't work in IE 7.

    Why not just collapse the margins and padding on all your main page elements (save for form controls) and then reset them manually where you need it?

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by anjanesh
    For browser differences,
    What browser differences are you talking about as I don't know of one that makes 2px extra padding necessary in IE ?

    It is likely that the issue could be resolved without a hack and as Dan mentioned it may be that you have not taken control of the default margins and padding that are applied by default and differ in various browsers.

    Only hack when you know it is a known bug (and even then a change of design (or change of approach) may make the hack unnecessary.)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •