title: How to draw rectange inside fix size rectange using percentage unit in CSS and HTML?
body: <p><a href="https://i.stack.imgur.com/9YqJi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9YqJi.png" alt="enter image description here" /></a></p>
  <p>I can draw such inner rectange inside fixed size rectange using absolute unit like in this code</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-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;title&gt;Test div dimension&lt;/title&gt;
      &lt;style&gt;
          #main {
              width: 640px;
              height: 360px;
              border: 1px solid black;
          }
  
          #content {
              width: 100%;
          }
  
          #slide {
              border: 1px solid red;
              width: calc(640*0.75px);
              height: calc(360*0.75px);
              float: right;
          }
  
          #camera {
              border: 1px solid red;
              width: calc(640 * 0.25px);
              height: calc(360 * 0.25px);
              float: left;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id="main"&gt;
          &lt;div id="content"&gt;
              &lt;div id="slide"&gt;
                  Rectange 1
              &lt;/div&gt;
              
              &lt;div id="camera"&gt;
                  Rectange 2
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>How can I use percentage(<code>%</code>) based unit instead of <code>px</code> to create such inner rectangles to avoid calculation like <code>calc(640*0.75px)</code>?</p>
  <p>I tried this but did not work</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-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;title&gt;Test div dimension&lt;/title&gt;
      &lt;style&gt;
          #main {
              width: 640px;
              height: 360px;
              border: 1px solid black;
          }
  
          #content {
              width: 100%;
          }
  
          #slide {
              border: 1px solid red;
              width: 75%;
              height: 75%;
              float: right;
          }
  
          #camera {
              border: 1px solid red;
              width: 25%;
              height: 25%;
              float: left;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id="main"&gt;
          &lt;div id="content"&gt;
              &lt;div id="slide"&gt;
                  Rectange 1
              &lt;/div&gt;
  
              &lt;div id="camera"&gt;
                  Rectange 2
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>