By default, a background extends to the border-box of the element. background-clip can be used to change this behaviour, i.e. to exclude padding:
background-clip: content-box;
This also can be used in the background shorthand.
text can also be used as a value, but the support is a little worse.
https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip