CSS background Property
CSS background Property
CSS background
property is a shorthand property of the following CSS properties
- background-color
- background-image
- background-position
- background-size
- background-repeat
- background-origin
- background-clip
- background-attachment
Example
Syntax
Using CSS
Using Javascript
Animatable
Yes, background property is animatable. CSS Animatable Properties Reference.
Default Value
Default value for CSS background property is white none 0% 0% auto repeat padding-box border-box scroll.
Property Value
Value | Type | Explanation |
---|---|---|
background-color | Required | Specifies the background color to be used. |
background-image | Optional | Specifies the background image color to be used |
background-position | Optional | Specifies the position of the background images. |
background-size | Optional | Specifies the size of the background images. |
background-repeat | Optional | Specifies how to repeat the background images. |
background-origin | Optional | Specifies the position of the background images. |
background-clip | Optional | Specifies how to clip the background-image. |
background-attachment | Optional | Specifies whether the image's position is fixed within the viewport, or scrolls with its containing block. |
Using JavaScript
In the following example, we will demonstrate how to change the CSS background
property of an element using JavaScript.
Example
Reminder
Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in CSS.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.