CSS: Backgrounds

Revision as of 12:20, 23 December 2022 by A mathemagician (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page shows how to create and use backgrounds in CSS.

Basics - Backgrounds - Text - Box Model - Selectors and Combinators - Pseudo-class and Pseudo-element - Gradients - Animations and Transitions - CSS in AoPS - List of Elements


You can use the background CSS property to modify the background of an element. The background consists of several parts.

Background Color

The background-color property modifies the color of the background. For example, the code

    background-color: red;

will create the following:

You can also use gradients instead of colors.

Background Image

You can use the background-image property to use an image instead of a color/gradient:

    background-image: url('/image.png');