CSS background-color 속성
예시
페이지의 배경색 설정:
body {background-color: coral;}
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
속성 은 background-color
요소의 배경색을 설정합니다.
요소의 배경은 패딩과 테두리(여백 제외)를 포함한 요소의 전체 크기입니다.
팁: 텍스트를 읽기 쉽게 배경색과 텍스트 색상을 사용하십시오.
기본값: | 투명한 |
---|---|
상속: | 아니요 |
애니메이션 가능: | 예. 애니메이션 가능 에 대해 읽기 |
버전: | CSS1 |
자바스크립트 구문: | 개체 .style.backgroundColor="#00FF00" |
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
background-color | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
CSS 구문
background-color: color|transparent|initial|inherit;
속성 값
Value | Description | Play it |
---|---|---|
color | Specifies the background color. Look at CSS Color Values for a complete list of possible color values. | |
transparent | Specifies that the background color should be transparent. This is default | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
더 많은 예
예시
HEX 값으로 배경색 지정:
body {background-color: #92a8d1;}
예시
RGB 값으로 배경색 지정:
body {background-color: rgb(201, 76, 76);}
예시
RGBA 값으로 배경색 지정:
body {background-color: rgba(201, 76, 76, 0.3);}
예시
HSL 값으로 배경색 지정:
body {background-color: hsl(89, 43%, 51%);}
예시
HSLA 값으로 배경색 지정:
body {background-color: hsla(89, 43%, 51%, 0.3);}
예시
다른 요소의 배경색 설정:
body {
background-color: #fefbd8;
}
h1 {
background-color: #80ced6;
}
div {
background-color: #d5f4e6;
}
span {
background-color: #f18973;
}
관련 페이지
CSS 튜토리얼: CSS 배경
HTML DOM 참조: backgroundColor 속성