-1
html, body, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, 
big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, 
sup, sub, tt, var, u, i, center, ul, ol, li, dl, dt, dd, tfoot, caption, form, fieldset, 
legend, input, button, textarea, select, label, applet, object, iframe, audio, video, 
canvas, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, 
nav, section, summary {
    font-family: inherit; line-height: inherit; 
    vertical-align: baseline; border: 0; outline: 0; padding: 0; margin: 0;
}

I don't want that to effect any elements inside div.base.

Do you have a solution?

Web_Designer
  • 72,308
  • 93
  • 206
  • 262
  • "I believe OP wants for the declaration he included in his question to apply to all cases, but NOT to children of div.base – Patrick Moore " – Lê Tuấn Anh May 12 '17 at 03:44
  • just rewrite those properties for `div.base` with `!important` –  May 12 '17 at 03:52

3 Answers3

0

Try the :not() selector.

The negation CSS pseudo-class, :not(X), has a functional notation taking a simple selector X as an argument. It matches elements that are not represented by the argument. X must not contain another negation selector. (from MDN)

* { } Styles all the elements. Adding :not(.base) to it excludes elements with class base.

*:not(#div1){
    color:red;
}

Example:

*:not(.base) {
  font-family: inherit;
  line-height: inherit;
  vertical-align: baseline;
  border: 0;
  outline: 0;
  padding: 0;
  margin: 0;
}
<body>
  <h1>Hello</h1>
  <div>
    <h1 class="base">Text</h1>
  </div>
</body>
Geethu Jose
  • 1,953
  • 2
  • 14
  • 30
0

Add this CSS rule which resets each of those properties for elements in div.base:

div.base * {
    font-family: initial; line-height: initial; 
    vertical-align: initial; border: initial; outline: initial; padding: initial; margin: initial;
}

The initial CSS keyword applies the initial value of a property to an element. —MDN

Web_Designer
  • 72,308
  • 93
  • 206
  • 262
-1

If your question is how do I apply a single CSS property or set of properties to everything then you can do this.

   * {
      font-family: inherit; 
      line-height: inherit; 
      vertical-align: baseline; 
      border: 0; 
      outline: 0; 
      padding: 0; 
      margin: 0;
    }
   div.base {
    #set properties for div.base here
   }
Mike Tung
  • 4,735
  • 1
  • 17
  • 24