How do padding, width&height relate to each other?

When I set a background color to a text element, someone told me this outlines not only the padding, but the height and width too. Are height and width theoretically the same as padding?

Here’s my code: https://code.sololearn.com/WIWJvKsVl4hq/#css

Padding is not the same as width and height. Think of the border as the edge of your content. Padding will push your content away from the border.

Also, your background color will stretch to fit all the way to the border.

1 Like