How does the padding property “expand the background-color”? Does the background-color property not apply to a box element’s margin and border?


#1

Question

How does the padding property “expand the background-color”? Does the background-color property not apply to a box element’s margin and border?

Answer

The background of an element includes an element’s content area, border and padding but not it’s margin. Hence, by increasing the border, the padding, the width, or the height of an element we can expand the area that gets affected by the background-color property.