--- title: background slug: Web/CSS/background tags: - CSS - CSS Background - CSS Property - Reference - 'recipe:css-shorthand-property' translation_of: Web/CSS/background ---
{{CSSRef("CSS Background")}}

CSS background 단축 속성은 색상, 이미지, 원점, 크기, 반복 등 여러 배경 스타일을 한 번에 지정합니다.

{{EmbedInteractiveExample("pages/css/background.html")}}

구성 속성

background는 단축 속성으로서 다음의 하위 속성을 포함합니다.

구문

/* <background-color> 사용 */
background: green;

/* <bg-image>와 <repeat-style> 사용 */
background: url("test.jpg") repeat-y;

/* <box>와 <background-color> 사용 */
background: border-box red;

/* 단일 이미지, 중앙 배치 및 크기 조절 */
background: no-repeat center/80% url("../img/image.png");

background 속성을 쉼표로 구분해서 배경 레이어를 여러 개 지정할 수 있습니다.

각 레이어의 구문은 다음과 같습니다.

<attachment>
{{cssxref("background-attachment")}}
<box>
{{cssxref("background-clip")}}, {{cssxref("background-origin")}}
<background-color>
{{cssxref("background-color")}}
<bg-image>
{{Cssxref("background-image")}}
<position>
{{cssxref("background-position")}}
<repeat-style>
{{cssxref("background-repeat")}}
<bg-size>
{{cssxref("background-size")}}

접근성 고려사항

브라우저는 배경 이미지에 대한 어떠한 추가 정보도 접근성 보조 기술에 제공하지 않습니다. 특히 스크린 리더의 경우 배경 이미지의 존재 유무조차 알려주지 않습니다. 이미지가 페이지 목적의 이해에 필수적인 정보를 갖고 있다면 문서에서 구조적으로 설명하는 편이 좋습니다.

형식 정의

{{cssinfo}}

형식 구문

{{csssyntax}}

예제

색상 키워드와 이미지를 사용한 배경

HTML

<p class="topbanner">
  작은 별<br/>
  반짝 반짝<br/>
  작은 별
</p>
<p class="warning">문단 하나<p>

CSS

.warning {
  background: pink;
}

.topbanner {
  background: url("https://mdn.mozillademos.org/files/11983/starsolid.gif") #99f repeat-y fixed;
}

결과

{{EmbedLiveSample("색상_키워드와_이미지를_사용한_배경")}}

명세

Specification Status Comment
{{SpecName('CSS3 Backgrounds', '#the-background', 'background')}} {{Spec2('CSS3 Backgrounds')}} The shorthand property has been extended to support multiple backgrounds and the new {{cssxref("background-size")}}, {{cssxref("background-origin")}} and {{cssxref("background-clip")}} properties.
{{SpecName('CSS2.1', 'colors.html#propdef-background', 'background')}} {{Spec2('CSS2.1')}} No significant changes
{{SpecName('CSS1', '#background', 'background')}} {{Spec2('CSS1')}} Initial definition

브라우저 호환성

{{Compat("css.properties.background")}}

같이 보기

Categoria