CSS Properties: How to set the background image start from the upper left corner of the content?
Solution:
HTML Code:
Explanation:
- Three div elements with different IDs (xyz1, xyz2, xyz3) are defined.
- Each div has a border, padding, and a background image.
- The background-origin property is used to specify the origin of the background image within the box (padding box or content box).
- The background image starts from the upper left corner of the content for the div with id xyz3, as its background-origin property is set to content-box.
- For the other two divs (xyz1 and xyz2), the default behavior is observed where the background image starts from the upper left corner of the padding box.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | No |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.