Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

6. CSS - Backgrounds

Lesson 6 of 34 in the free CSS Customization: Zero to Hero notes on Siksha Sarovar, written by Rohit Jangra.

CSS Backgrounds

The background properties are used to define the background effects for an element.

1. background-color

Specifies the background color of an element.

body {
  background-color: lightblue;
}

2. background-image

Specifies an image to use as the background of an element.

body {
  background-image: url("paper.gif");
}

3. background-repeat

Sets how a background image will be repeated.

  • repeat: Repeats both vertically and horizontally (default).
  • repeat-x: Repeats only horizontally.
  • repeat-y: Repeats only vertically.
  • no-repeat: The image is not repeated.

4. background-attachment

Sets whether a background image is fixed or scrolls with the rest of the page.

  • scroll: The background scrolls with the element.
  • fixed: The background is fixed with regard to the viewport.

5. background-position

Sets the starting position of a background image.

body {
  background-position: right top;
}
Shorthand Property: You can specify all background properties in one single property: background: #ffffff url("img_tree.png") no-repeat right top;