CSS Background Image
The background-image property allows you to display an image behind the content of an HTML element. It's a fundamental property for creating visually appealing web pages, hero sections, and UI cards.
The URL Function
To specify the image, you use the url() function. The value inside can be a relative or absolute path to the image file. By default, the image is placed at the top-left corner of the element and repeated vertically and horizontally.
Controlling Repetition
Often, you don't want the image to tile. The background-repeat property controls this behavior.
repeat: The default behavior (tiles in both directions).no-repeat: Shows the image only once.repeat-x: Tiles horizontally only.repeat-y: Tiles vertically only.
Sizing and Positioning
Size: Use background-size: cover to make the image fill the entire container, cropping it if necessary to maintain aspect ratio. Use contain to ensure the whole image is visible.
Position: Use background-position to control where the image sits within the container (e.g., center, top right).
