CSS Backgrounds

Estimated reading: 1 minute 38 views

Inherited: No

Background
You can style the background of an element in one declaration with the
background property

 background: #ffffff url(path_to_image) top left no-repeat fixed;

Values:

  • attachment
  • color
  • image
  • position
  • repeat
  • Or you can set each property individually

Background Image
You can set an image for the background of an element using the
background-image property.

 background-image: url(path_to_image);

Values:

  • url
  • none

Background Position

 background-position: value;

Values:

  • top left
  • top center
  • top right
  • center left
  • center center
  • center right
  • bottom left
  • bottom center
  • bottom right
  • x-% y-%
  • x-pos y-pos

Background Repeat

You can set if an image set as a background of an element is to repeat
(across=x and/or down=y) the screen using the background-repeat
property.

 background-repeat: value;

Values:

  • no-repeat
  • repeat
  • repeat-x
  • repeat-y
Share this Doc

CSS Backgrounds

Or copy link