How do I prevent the padding property from changing width or height in CSS?

I am creating a site with DIVs. Everything’s working out except when I create a DIV. I create them like this (example):

newdiv {
    width: 200px;
    height: 60px;
    padding-left: 20px;
    text-align: left;
}

When I add the padding-left property, the width of the DIV changes to 220px, and I want it to remain at 200px.

Let’s say I create another DIV named anotherdiv exactly the same as newdiv, and put it inside of newdiv but newdiv has no padding and anotherdiv has padding-left: 20px. I get the same thing, newdiv‘s width will be 220px.

How can I fix this problem?

9 Answers
9

Leave a Comment