CSS background-color 속성

정의 및 사용법

background-color attribute sets the background color of the element.

element background scope

background-color attribute to set an element a solid color. This color will fill the element's content, padding, and border area, extending to the outer boundary of the element's border (but not including the margin). If the border has a transparent part (such as a dashed border), the background color will show through these transparent parts.

투명 값

尽管在大多数情况下,没有必要使用 투명하지만如果您 do not want an element to have a background color, and do not want the user's browser color settings to affect your design, then set 투명 값은 필요합니다.

추가로 참조:

CSS 강의:CSS 배경

HTML DOM 참조 가이드:backgroundColor 속성

예제

다른 요소에 배경색을 설정합니다:

body
  {
  background-color:yellow;
  }
h1
  {
  background-color:#00ff00;
  }
p
  {
  background-color:rgb(255,0,255);
  }

직접 시험해 보세요

CSS 문법

background-color: 색상|transparent|initial|inherit;

속성 값

설명
color_name 색상 값이 색상 이름의 배경색을 정의합니다. (예: red).
hex_number 색상 값이 16진수의 배경색을 정의합니다. (예: #ff0000).
rgb_number 색상 값이 rgb 코드의 배경색을 정의합니다. (예: rgb(255,0,0)).
투명 기본적으로. 배경색은 투명입니다.
inherit 부모 요소에서 background-color 속성 설정을 상속해야 합니다.

기술 세부 사항

기본값: 투명
상속성: 아니요
버전: CSS1
자바스크립트 문법: 오브젝트.style.backgroundColor="#00FF00"

브라우저 지원

표中之수는 해당 속성을 최초로 지원하는 브라우저 버전을 나타냅니다.

크롬 엣지 파이어폭스 사파리 오페라
크롬 IE / 엣지 파이어폭스 사파리 오페라
1.0 4.0 1.0 1.0 3.5