Please enable Javascript for better experience...
Background-Clip and Background-Origin in CSS
By Rahul Kumar Jha | Mar 27, 2016 | In Articles | Total Views [ 3413 ]
Taged In
(1 Like)

Background-origin and background-clip property is nearly same but has little difference.


In below sections, we will see the difference between background-origin and background-clip. Both properties have three options: border-box, padding-box, and content-box. The background-origin property determines where the background is placed. While the background-clip determines what part of the background is shown. The properties can be used together or independently.

Default attribute


Attribute: border-box


Attribute: padding-box


Attribute: content-box


Let's see the full example


        background-image: url(bimg.png);
        display: inline-block;
        width: 500px;
        height: 250px;
        color: #fcfa05;
        padding: 20px;
        border: 10px dashed #333;
        font-size: 2em;
        font-weight: bold;
        margin: 0 0 20px 20px;
    div span{
    font-size: 1em;
    color: #fff;
<h1>Below you can see the comparison between Background-Origin and Background-Clip based on their attributes.</h1>
    <h2>Default behaviour</h2>
        <span>Default behaviour is border-box</span>
        <span>Default behaviour is border-box</span>
    <h2>Attribute: border-box</h2>
    <div style="background-origin: border-box; background-repeat: no-repeat;">
        background-origin : border-box<br/>
        <span>Border is overlapping image</span>
    <div style="background-clip: border-box;">
        background-clip : border-box<br/>
        <span>Border is overlapping image</span>
    <h2>Attribute: padding-box</h2>
    <div style="background-origin: padding-box; background-repeat: no-repeat;">
        background-origin : padding-box
        <span>See the side corners. Image has padding in left but not in right side.</span>
    <div style="background-clip: padding-box;">
        background-clip : padding-box
        <span>See the side corners. Both side has equal padding. Border is not overlapping image.</span>
    <h2>Attribute: content-box</h2>
    <div style="background-origin: content-box; background-repeat: no-repeat;">
        background-origin : content-box
        <span>Image is shifted toward content but at the right corner, image and border is overlapping each other.</span>
    <div style="background-clip: content-box;">
        background-clip : content-box<br/>
        <span>Image and border has equal space at all corners and image has shifted toward content.</span>

Hope it helps you. You can download the working example also.

Share this

About the Author

Rahul Kumar Jha
Rahul Kumar Jha
Founder, Developer

Public profile: user/profile/99900001

Has working experience in different phases of Software Development Life Cycle (SDLC) in CMS, Gaming, Health Care and Financial Services domain using Agile pattern. Working experience in Design patterns, ASP.NET, MVC, ANGULAR, ANGULAR JS, Windows application, WCF, ADO.NET, SQL Server and Test Driven Development (TDD) environment with JQuery, JavaScript, N-Unit, Entity Frameworks, LINQ, Code Refactoring and Business Objects Models.

User's Comments

Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID