CSS | background-origin property
The background-origin is a property defined in CSS which helps in adjusting the background image of the webpage. This property is used to set the origin of the image in the background. By default, this property sets the background image origin to the upper-left corner of the screen/webpage.
Syntax:
background-origin: padding-box|border-box|content-box|initial| inherit;
Property Value:
initial: This takes the initial/default value of setting the background origin to the padding edge int the upper left corner.
- Syntax:
background-origin: initial;
- Example:
<!DOCTYPE html><html><head><title>background-origin property</title><style>.gfg {padding: 40px;width: 400px;background-image:background-repeat: no-repeat;background-origin: intial;border: 1px double;text-align: justify;}</style></head><body><divclass="gfg"><p>Prepare for the Recruitment drive of productbased companies like Microsoft, Amazon, Adobeetc with a free online placement preparationcourse. The course focuses on various MCQ's& Coding question likely to be asked in theinterviews & make your upcoming placementseason efficient and successful.</p></div></body></html>chevron_rightfilter_none - Output:
padding-box: This property is used to set the origin of the background image to the padding edge in the upper left corner.
- Syntax:
background-origin: padding-box;
- Example:
<!DOCTYPE html><html><head><title>background-origin property</title><style>.gfg {padding: 40px;width: 400px;background-image:background-repeat: no-repeat;background-origin: padding-box;border: 1px double;text-align: justify;}</style></head><body><divclass="gfg"><p>Prepare for the Recruitment drive ofproduct based companies like Microsoft,Amazon, Adobe etc with a free onlineplacement preparation course. The coursefocuses on various MCQ's & Coding questionlikely to be asked in the interviews &make your upcoming placement seasonefficient and successful.</p></div></body></html>chevron_rightfilter_none - Output:

border-box: This property is used to set the image to the border of the body of the webpage i.e. the absolute upper left corner.
- Syntax:
background-origin: border-box;
- Example:
<!DOCTYPE html><html><head><title>background-origin property</title><style>.gfg {padding: 40px;width: 400px;background-image:background-repeat: no-repeat;background-origin: border-box;border: 1px double;text-align: justify;}</style></head><body><divclass="gfg"><p>Prepare for the Recruitment drive ofproduct based companies like Microsoft,Amazon, Adobe etc with a free onlineplacement preparation course. The coursefocuses on various MCQ's & Coding questionlikely to be asked in the interviews & makeyour upcoming placement season efficientand successful.</p></div></body></html>chevron_rightfilter_none - Output:

content-box: This property is used to set the origin of the background according to the content of the division/body wherever the property is being used.
- Syntax:
background-origin: content-box;
- Example:
<!DOCTYPE html><html><head><title>background-origin property</title><style>.gfg {padding: 40px;width: 400px;background-image:background-repeat: no-repeat;background-origin: content-box;border: 1px double;text-align: justify;}</style></head><body><divclass="gfg"><p>Prepare for the Recruitment drive ofproduct based companies like Microsoft,Amazon, Adobe etc with a free onlineplacement preparation course. The coursefocuses on various MCQ's & Coding questionlikely to be asked in the interviews & makeyour upcoming placement season efficientand successful.</p></div></body></html>chevron_rightfilter_none - Output:

inherit: It is used to inherit the property from already used code (parent property) else works as padding-box by default.
- Syntax:
background-origin: inherit;
- Example:
<!DOCTYPE html><html><head><title>background-origin property</title><style>.gfg {padding: 40px;width: 400px;background-image:background-repeat: no-repeat;background-origin: inherit;border: 1px double;text-align: justify;}</style></head><body><divclass="gfg"><p>Prepare for the Recruitment drive ofproduct based companies like Microsoft,Amazon, Adobe etc with a free onlineplacement preparation course. The coursefocuses on various MCQ's & Coding questionlikely to be asked in the interviews & makeyour upcoming placement season efficient andsuccessful.</p></div></body></html>chevron_rightfilter_none - Output:
Supported Browsers: The browsers supported by CSS | background-origin property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Style backgroundOrigin Property
- CSS | transition-property Property
- CSS | nav-right property
- CSS | right Property
- CSS | nav-down property
- CSS | top Property
- CSS | all Property
- CSS | animation-name Property
- CSS | The object-fit Property
- CSS | grid-gap Property
- HTML | DOM Bdo dir Property
- CSS | visibility Property
- HTML | DOM URL Property
- HTML | DOM name Property
- CSS | grid-row Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



