[For beginners] Visualizing how some CSS rules act.

When you start to write code with CSS. It is all confusing so let's understand with chair and sofas

Trying to visualise what an inline, block element, margin, padding and align looks like through chairs and sofa.

Imagine a row where only a few chairs a present. The row has more space to add chairs.

Then there is another row where a giant sofa is occupying the whole row.

Chair is an inline element. It occupies only a part of the row. Sofa is a block element. It is big and occupies the whole row.

Now imagine 5 chairs are in line in one row. 4 people come in to occupy the chairs. One person sits on one chair. And then 2nd, 3rd and the 4th person comes.

Now the 3rd person is sandwiched between 2 and 4 and wants more space to feel comfortable. So he asks for more margin.

The 3rd person also has a bag with them and the chair can accommodate their bag also but for that they need to make space in the chair itself so they add space (padding) to include their bag also.

Now the chair row can accomodate 5 more chairs if margin is kept as it is. But if they want more space between chairs then probably number of chairs will need to be reduced that can be further added.

Inside what space the chair has to sit, probably someone would want to sit only towards left ( like the trainee rickshaw person learning to drive with the instructor ) They can 'align' themselves inside the chair.