www.webdeveloper.com
Results 1 to 4 of 4

Thread: !important;

  1. #1
    Join Date
    May 2007
    Posts
    115

    Post !important;

    For so long I been using this type of code:

    .tdc6
    {
    height:150px; /# height:172px;
    width:140px; /# width:150px;
    border:0px solid;
    float:left;
    padding:5px;
    position:relative;
    left:0px;
    top:15px;
    }

    But now I find out that can be make it with !important; instead of /# I should change all my old code to ' !important; ' or will be ok if I leave it with ' /# '

    pls help they going to evaluate my work for see if i can get a promotion this year

  2. #2
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    Quote Originally Posted by liccy
    For so long I been using this type of code:

    .tdc6
    {
    height:150px; /# height:172px;
    width:140px; /# width:150px;
    border:0px solid;
    float:left;
    padding:5px;
    position:relative;
    left:0px;
    top:15px;
    }

    But now I find out that can be make it with !important; instead of /# I should change all my old code to ' !important; ' or will be ok if I leave it with ' /# '

    pls help they going to evaluate my work for see if i can get a promotion this year
    I think that !important overrides the prevailing CSS to 'do this instead', while /# height:other is a 'hack' that targets IE because IE (incorrectly) obeys the selector:declaration that come after the 'slash' (you're taking advantage of an IE flaw to a betterment for that browser only), while compliant browsers will ignore /# height:other; in lieu of the correct first stated value.

    The 'slash hack' may have been corrected ("made unnecessary") for IE7 (which I do not use), therefore, better to get away from using lt-IE6 'hacks', -which only props-up older browser acceptance and continued use.
    -When the world gets tired of old, buggy IE, the demand for compliant correct browsers (and website code) will become the norm. Myself, I am quite loathe to come across websites with the ubiquitous "best viewed in IE" disclaimer...

    A better way than !important to get compliant and IE browsers to render content the same way, is to 'zero out' the main offenders, usually these are margin, padding and sometimes, border:

    * {margin:0; padding:0; border:0;}

    This is called the 'universal selector' method. It strips all margins, paddings and borders, from everything that you document may contain (table, tr td, div, p, all h-tags, form, -everything), then, re-state the values to the amount you want and ALL browsers (including IE) will be forced to comply.

    This often eliminates the need for !important overrides.

    Next, a good default-stating of all h-tags and font-size would be in order.
    I build for: Firefox and tweak for IE

  3. #3
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Some versions of IE do not obey !important so you can set standard values in a property tagged as !important and follow it up with one for IE that is not !important. It's a hack like any other but it's one that hopefully will degrade gracefully when the version of IE applying the style acts in a standard manner.
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

  4. #4
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    border:0px solid;
    float:left;
    padding:5px;
    position:relative;
    left:0px;
    top:15px;


    I wonder, -I have seen "border: 0px solid;" used like this before... it serves no purpose. It's just a couple of bytes of useless bloat(?), -the page could survive without it I wonder?

    Noted, "position:relative; left:0 ; top:15px;". If all you want here is a 15-pixel 'header spacing', again, the smaller code could be "margin-top:15px;".
    Note too, that any value of "zero", you can omit the "px" (or whatever units used), as 0: px = 0: em = 0: pt, etc etc... Zero is zero, -no matter what units the measure is. Applied consistantly, this can reduce a page-size by a notable percent for faster downloads and reduced bandwidth.

    And remember, 'whitespace' is counted too.

    Code:
    body       {        this  :  that;    this  :  that;        }
    body {this:that; this:that;}
    says the same thing, but the second version is slightly smaller in bit-size. And to be 100% precise, the last " ; " between the "{" and "}", is actually unnecessary.
    I build for: Firefox and tweak for IE

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles