Use flex-basis Property to Set the Initial Size of an Item

Tell us what’s happening: can’t we just use height and width property to set the initial size of the item?

Your code so far

  #box-container {
    display: flex;
    height: 500px;
  #box-1 {
    background-color: dodgerblue;
    height: 200px;
   FLEX-BASIS: 10em;
  #box-2 {
    background-color: orangered;
    height: 200px;
    flex-basis: 20em;
<div id="box-container">
  <div id="box-1"></div>
  <div id="box-2"></div>

Your browser information:

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

Link to the challenge:

1 Like

Good question. The main difference is that flex-basis will work on width or height depending if your flex-direction is row or column respectively, while width and height works only on their respective axis.

There’s a great answer on stack overflow if you want to know more: