VOOZH about

URL: https://www.geeksforgeeks.org/css/how-to-add-background-image-in-css/

⇱ How to Add Background Image in CSS? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Add Background Image in CSS?

Last Updated : 19 Nov, 2024

The CSS background-image property is used to add an image as a background to an element.

Syntax

background-image: url()

1. Setting background Image of an Element

A background image is added to an h1 tag using the URL.

Output

👁 background-image
Background-image

2. Setting Background Size

The size of the background image can be set using the background-size property.

Syntax

background-size: value;

Output

👁 background-cover
background-cover

3. Positioning the Background Image

The background-position property allows you to position the background image within the element.

Syntax

background-position: value

Output

👁 output
background-position

4. Repeating Background Images

The repetition of the background-image can be set using the background-repeat property.

Syntax

background-repeat: repeat

Output

👁 repeating-image
Background-repeat property
Comment
Article Tags: