Ok, here is a div , and his name is Blue. Say hello to Blue:
div.Blue { width: 100px; height: 100px; background-color: blue; }

Here is his friend Grinney. Say hello to Greenny:
div.Greenny { width: 100px; height: 100px; background-color: blue; border: 20px solid green; }

Greenny is 40px wider and taller than Blue, so he decided to go on a diet:
div.GreennyAfterTheDiet { width: 100px; height: 100px; background-color: blue; border: 20px solid green; box-sizing: border-box; }
Now its width and height are 100px, including the borders:

This is pretty simple, as you can see. The same rule works for filling.
UPD: Here is a simple utility:
HTML
<div>bla bla bla bla bla bla bla bla bla bla</div> <div>bla bla bla bla bla bla bla bla bla bla</div> <div>bla bla bla bla bla bla bla bla bla bla</div> <div>bla bla bla bla bla bla bla bla bla bla</div>
CSS
div { width: 25%; float: left; background-color: #ffd862; }
The result will look like this:

But if you want to add some add-ons

See what happened? Now I will add box-sizing: border-box; :

And now divs have a width: 25% again, but also have padding: 10px at the same time.
source share