title: How to use an inheritance height in css?
body: <p>I want to talk about inheritance in CSS. If the parent has the <code>height</code> attribute (<code>100%</code>), then every child which wants to inherit that height, it can be declared directly. I mean: no need to set sub-parent's height to 100%.</p>
  
  <p>Like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    height: 200px;
  }
  
  .div_1 {
    height: 100%;
  }
  
  .div_2 {
    height: 100%;
  }
  
  .div_3 {
    height: 100%;
    background-color: #ccc;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="div_1"&gt;
    &lt;div class="div_2"&gt;
      &lt;div class="div_3"&gt;foo&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The root height is: <code>200px</code>. <code>body</code> is a parent tag, <code>.div_3</code> is a child tag. So, if I want to use the same height with <code>body</code> tag, I have to define the height of <code>.div_1</code> and <code>.div_2</code>.</p>
  
  <p>If not, it should be:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    height: 200px;
  }
  /*
  .div_1 {
    height: 100%;
  }
  
  .div_2 {
    height: 100%;
  }
  */
  .div_3 {
    height: 100%;
    background-color: #ccc;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="div_1"&gt;
    &lt;div class="div_2"&gt;
      &lt;div class="div_3"&gt;foo&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>It looks okay if I have only 3 div tags, what's happen if I have a template like this:</p>
  
  <pre><code>&lt;div class="div_1"&gt; &lt;!-- need an 'inherit' height --&gt;
      &lt;div class="this"&gt; &lt;!-- need an 'inherit' height --&gt;
          &lt;div class="is"&gt; &lt;!-- need an 'inherit' height --&gt;
              &lt;div class="a"&gt; &lt;!-- need an 'inherit' height --&gt;
                  &lt;div class="lot"&gt; &lt;!-- need an 'inherit' height --&gt;
                      &lt;div class="of"&gt; &lt;!-- need an 'inherit' height --&gt;
                          &lt;div class="sub-parent"&gt; &lt;!-- need an 'inherit' height --&gt;
                              &lt;div class="div_2"&gt; &lt;!-- need an 'inherit' height --&gt;
                                  &lt;div class="div_3"&gt;foo&lt;/div&gt; &lt;!-- height: 100% --&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Why do we need to do the same thing for every sub-parent? <code>height: 100%;</code> or <code>height: inherit;</code>?</p>
  
  <p>It should be wasting time.</p>