Background Properties

PropertyPossible ValuesDescription
background-colorcolor-name, hex, rgb, rgbaSets the background color of an element
background-imageurl('image.jpg'), noneSets an image as the background
background-positionleft, right, center, px, %Defines the position of the background image
background-sizeauto, cover, contain, px, %Defines the size of the background image
background-repeatrepeat, no-repeat, repeat-x, repeat-yControls how the background image repeats
background-attachmentscroll, fixed, localSpecifies whether the background scrolls with the page
backgroundShorthand for all background propertiesExample: background: url('image.jpg') no-repeat center/cover;

Example:

body {
    background-color: #f0f0f0;
    background-image: url('background.jpg');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
}
✔ Light gray background color
✔ Full-screen background image
✔ No image repetition
✔ Image remains fixed while scrolling
Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz