Managing div width & height with ‘box-sizing’

Let’s say we have two divs side by side, each taking 50% of the width.
We want to use padding in order to style the content inside, but the padding enlarges the width of the divs and makes them appear one below the other. The solution is using “box-sizing: border-box;” in CSS to tell the browser that the 50% width is for the entire element including padding and borders.

Leave a Reply

Your email address will not be published. Required fields are marked *