0% completed
Background shorthand lets you combine multiple background properties into one line. Instead of writing each property separately, you can set the background color, image, repeat, attachment, and position all at once. This makes your CSS cleaner and easier to manage.
Follow the code block below to use the background shorthand in CSS:
background: background-color background-image background-repeat background-attachment background-position;
Explanation:
repeat
, no-repeat
, etc.).scroll
, fixed
).In this example, we set a background color, add a background image, and control the image repeat and position using the shorthand property.
Explanation:
In this example, we use the background shorthand to also include the attachment property. This example shows how to set the background so that the image is fixed while you scroll.
Explanation:
This lesson demonstrates how to use the background shorthand to combine several properties into one concise rule. This approach simplifies your CSS and makes it easier to maintain.
.....
.....
.....