Background Color

Syntax: background-color: color|transparent|initial|inherit;

Background Color with Value

Syntax: background-color: yellow;

Background Color Opacity

Syntax: background-color: rgba(255,255,255,.5);

Background Color Transparent

Syntax: background-color: transparent;

Background Image

Syntax: background-image: url|none|initial|inherit;

Background Image URL

Syntax: background-image: url(http://image-url.jpg);

Background Image None

Syntax: background-image: none;

Background Position

Syntax: background-position: value;

EXAMPLES background-position: right center; (right center using keywords) background-position: 0 0; (left top using position) background-position: 50% 50%; (center center using %) background-position: 50px 50px; (50px from left 50px from top using pixels)

Next Section

Background Size

Syntax: background-size: auto|length|cover|contain|initial|inherit;

EXAMPLES background-size: 300px 300px; (absolute length using pixels) background-size: 50% 50%; (length using %, percentage of the container) background-size: cover; (cover entire container) background-size: contain; (whole image within container)

Next Section

Background Repeat

Syntax: background-repeat: repeat|repeat-x|repeat-y|no-repeat|initial|inherit;

EXAMPLES background-repeat: repeat; (repeat horizontally and vertically) background-repeat: repeat-x; (repeat horizontally) background-repeat: repeat-y; (repeat vertically) background-repeat: no-repeat; (don’t repeat)

Next Section

Background Origin

Syntax: background-origin: padding-box|border-box|content-box|initial|inherit;

Background Origin Padding Box

 

Syntax: background-origin: padding-box;

Background Origin Border Box

 

Syntax: background-origin: border-box;

Background Origin Content Box

 

Syntax: background-origin: content-box;

Background Clip

Syntax: background-clip: border-box|padding-box|content-box|initial|inherit;

Background Clip Border Box

 

Syntax: background-clip: border-box;

Background Clip Padding Box

 

Syntax: background-clip: padding-box;

Background Clip Content Box

 

Syntax: background-clip: content-box;

Background Attachment

Syntax: background-attachment: scroll|fixed|local|initial|inherit;

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Donec sollicitudin molestie malesuada. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Pellentesque in ipsum id orci porta dapibus. Cras ultricies ligula sed magna dictum porta.

Background Attachment Scroll

 

Syntax: background-attachment: scroll;

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Donec sollicitudin molestie malesuada. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Pellentesque in ipsum id orci porta dapibus. Cras ultricies ligula sed magna dictum porta.

Background Attachment Fixed

 

Syntax: background-attachment: fixed;

Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Donec sollicitudin molestie malesuada. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Pellentesque in ipsum id orci porta dapibus. Cras ultricies ligula sed magna dictum porta.

Background Attachment Local

 

Syntax: background-attachment: local;

Shorthand

Syntax: background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment;

Example: Not Shorthand

Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Nulla porttitor accumsan tincidunt. Curabitur aliquet quam id dui posuere blandit. Donec rutrum congue leo eget malesuada. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Donec rutrum congue leo eget malesuada. Proin eget tortor risus. Pellentesque in ipsum id orci porta dapibus. Donec sollicitudin molestie malesuada. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Nulla porttitor accumsan tincidunt. Curabitur aliquet quam id dui posuere blandit. Donec rutrum congue leo eget malesuada. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus.

background-color: red; background-image: url(https://sampsonfamily.me/wp-content/uploads/2017/07/yellowstone.jpg); background-position: left bottom; background-size: cover; background-repeat: no-repeat; background-origin: border-box; background-clip: padding-box; background-attachment: fixed;

Example: Shorthand

Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Nulla porttitor accumsan tincidunt. Curabitur aliquet quam id dui posuere blandit. Donec rutrum congue leo eget malesuada. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Donec rutrum congue leo eget malesuada. Proin eget tortor risus. Pellentesque in ipsum id orci porta dapibus. Donec sollicitudin molestie malesuada. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Nulla porttitor accumsan tincidunt. Curabitur aliquet quam id dui posuere blandit. Donec rutrum congue leo eget malesuada. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus.

background: red url(https://sampsonfamily.me/wp-content/uploads/2017/07/yellowstone.jpg) top center/ cover no-repeat border-box padding-box fixed;