Unexpected outcome using the padding property - Use Clockwise Notation

Tell us what’s happening:
I don’t understand why despite red box having 40px padding on left and right, the two boxes look the same.

Your code so far


<style>
  .injected-text {
    margin-bottom: -25px;
    text-align: center;
  }

  .box {
    border-style: solid;
    border-color: black;
    border-width: 5px;
    text-align: center;
  }

  .yellow-box {
    background-color: yellow;
    padding: 20px 40px 20px 40px;
  }
  
  .red-box {
    background-color: crimson;
    color: #fff;
    padding: 20px 40px 20px 40px;
  }

  .blue-box {
    background-color: blue;
    color: #fff;
    padding: 40px 20px 40px 20px;
  }



</style>
<h5 class="injected-text">margin</h5>

<div class="box yellow-box">
  <h5 class="box red-box">padding</h5>
  <h5 class="box blue-box">padding</h5>
</div>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36.

This isn’t unexpected, as your blue and red box have a block level element i.e. h5, it takes up the 100% width, and because you have centered it horizontally using text-align, it ignores the horizontal padding and only reflects vertical padding.
**

Try removing text align prop and you will see the actual padding effect.

**
Hope this helped clear your doubt.