Grow your CSS skills. Land your dream job.

Exclude a CSS rule defined on an HTML tag

  • # January 30, 2013 at 6:26 am

    Hi all,

    div
    {
    font-size:14px;
    font-family:Times New Roman;
    position:relative;
    float:left;
    }

    That is a css rule applied in a page that I need to work. I have no control over altering that. Now I need to put a div element in the page to which those rules should NOT apply. How do I do that? Any help is greatly appreciated.

    Thanks in advance,
    Renuka Prasad.

    # January 30, 2013 at 6:28 am

    Three options here:
    * Don’t use a div
    * Override styles with higher specificity
    * Use the !important hammer bash

    I’d go with the 2nd one I guess.

    # January 30, 2013 at 6:50 am

    Thank you for the quick response Hugo :)
    How do I override that CSS rule? (Assume target browsers are all CSS2 compliant)

    # January 30, 2013 at 7:58 am

    Can you class your new div and add css to target that class?

    # January 30, 2013 at 7:59 am

    What @Wolfcry911 said. You could also use an ID even if I wouldn’t recommand it.

    # January 30, 2013 at 8:45 am

    Thank you Wolfcry and Hugo, did it with a different class.

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

You must be logged in to reply to this topic.

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