Grow your CSS skills. Land your dream job.

inline !important css issue

  • # July 6, 2013 at 10:40 am

    Hello,

    How do i solve inline !important ;?

    i tired !important !important but its not work .

    !important !important property is right kind property or not ?
    plz clear this issue n help me.

    http://codepen.io/anon/pen/Eparg

    # July 6, 2013 at 10:45 am

    Why are you using `!important`?

    You can’t double up on it and make it “stronger”.

    Inline CSS will, as a general rule, override any CSS in your stylesheet assuming the same level of specificity.

    # July 6, 2013 at 10:47 am

    declaration space !important single one;

    width:1000px !important;

    having important both inline and in css file the inline declaration applies

    # July 6, 2013 at 10:49 am

    The only way to override inline styles is using `!important` in your stylesheet, unless… the inline style already has `!important`.

    Short answer: impossible.

    # July 6, 2013 at 12:08 pm

    Not impossible: you can override it by adding another inline style after that:

    But that’s definitely the only way, I think.

    # July 6, 2013 at 12:27 pm

    Oh yeah, when I said impossible I meant from within a stylesheet of course :)

    # July 6, 2013 at 12:43 pm

    a solution is to remove the style attribute all together and then set the width manually if thats the only style you want to apply or add a class with all the styles you want

    $(‘.fluid’).removeAttr(‘style’).css(‘width’,’100px’);

    im using jquery in the example

    # July 8, 2013 at 12:57 am

    Thanks

    # July 8, 2013 at 1:35 am

    hi,
    you no need to use !important in your inline style. you just add float:left;

    .fluid {
    width:100% ;
    background:#555;
    color:#fff;
    float:left;
    }

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".