Background Shorthand Property

Last updated: 2026-09-13

background Background Shorthand Property

background is the shorthand for the background properties, letting you set the background color, image, position, size, repetition, and more in a single declaration. The shorthand keeps code concise, and any sub-property you omit is reset to its default value. It is one of the most widely used shorthands in CSS.

Category
Initial Valuetransparent none repeat scroll 0% 0% auto padding-box border-box
InheritedNo
Applies Toall
Animation Typeshadow
CSS VersionCSS1
StatusStandard

📝 Syntax

background: [<bg-color> || <bg-image> || <bg-repeat> || <bg-position> [ / <bg-size> ]? || <bg-attachment> || <bg-clip> || <bg-origin>];

⚙️ Values

ValueTypeDescription
<bg-layer>*, <final-bg-layer>ValueBackground shorthand

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
background v1 v12 v1 v1 v1
Supported in all major browsers
Tip: In the shorthand, background-size must follow background-position, separated by a slash, e.g. center/cover.
Warning: The shorthand resets every unspecified background sub-property to its initial value, which may override previous individual settings.

❓ FAQ

QShould I use the background shorthand or set sub-properties individually?
AThe shorthand is best for defining a complete background at once, e.g. background: #fff url(bg.jpg) no-repeat center/cover; is compact. Individual properties are safer when you only want to change one sub-property (say background-size) without resetting the others. Note that the shorthand resets omitted sub-properties to defaults, so 'shorthand first, then individual' often causes surprises.
QDoes the value order in the background shorthand matter?
AOrder is fairly flexible because browsers identify values by type, but two rules are hard requirements: background-size must immediately follow the position and be separated by a slash (e.g. center/cover), and background-color must come last. The recommended order is color, then image, then repeat, then position/size.
QHow do I make a background image cover the whole element with the shorthand?
AOne line does it: background: #333 url(photo.jpg) no-repeat center/cover;. It is equivalent to setting the background color, image, no-repeat, horizontal and vertical centering, and cover sizing that fills the container while keeping the aspect ratio. This is the standard pattern for banners and card backgrounds — concise and hard to get wrong.
QWhich sub-properties does the background shorthand reset?
AEverything you do not explicitly write is reset to its initial value: image to none, repeat to repeat, position to 0% 0%, size to auto, attachment to scroll, clip to border-box, and origin to padding-box. So avoid mixing 'shorthand then individual' patterns for background sub-properties.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏