treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Exclude a CSS rule defined on an HTML tag

  • 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.

  • 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.

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

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

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

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