이 번역은 완료되지 않았습니다. 이 문서를 번역해 주세요.

color CSS 속성은 요소의 텍스트 및 텍스트 꾸밈의 전경 색상 값을 설정합니다. 또한 currentcolor를 바꿔 다른 속성도 간접적으로 설정할 수 있습니다. 이는 border-color와 같은 일부 속성의 기본값입니다..

HTML에서 색을 쓰는 법을 보시려면 Applying color to HTML elements using CSS을 참고하세요.

구문

/* Keyword values */
color: currentcolor;

/* <named-color> values */
color: red;
color: orange;
color: tan;
color: rebeccapurple;

/* <hex-color> values */
color: #090;
color: #009900;
color: #090a;
color: #009900aa;

/* <rgb()> values */
color: rgb(34, 12, 64, 0.6);
color: rgba(34, 12, 64, 0.6);
color: rgb(34 12 64 / 0.6);
color: rgba(34 12 64 / 0.3);
color: rgb(34.0 12 64 / 60%);
color: rgba(34.6 12 64 / 30%);

/* <hsl()> values */
color: hsl(30, 100%, 50%, 0.6);
color: hsla(30, 100%, 50%, 0.6);
color: hsl(30 100% 50% / 0.6);
color: hsla(30 100% 50% / 0.6);
color: hsl(30.0 100% 50% / 60%);
color: hsla(30.2 100% 50% / 60%);

/* Global values */
color: inherit;
color: initial;
color: unset;

color 속성은 하나의 <color> 값을 사용해 지정합니다.

값이 단일 색상이어야 함에 주의하세요. <gradient>는 사실 <image> 자료형이기 때문에 사용할 수 없습니다.

<color>
요소의 텍스트와 꾸밈 부분의 색을 설정.

형식 구문

<color>

where
<color> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hex-color> | <named-color> | currentcolor | <deprecated-system-color>

where
<rgb()> = rgb( <percentage>{3} [ / <alpha-value> ]? ) | rgb( <number>{3} [ / <alpha-value> ]? ) | rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )
<rgba()> = rgba( <percentage>{3} [ / <alpha-value> ]? ) | rgba( <number>{3} [ / <alpha-value> ]? ) | rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )
<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )
<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )

where
<alpha-value> = <number> | <percentage>
<hue> = <number> | <angle>

예제

아래 예제는 모두 텍스트를 빨갛게 만듭니다.

p { color: red; }
p { color: #f00; }
p { color: #ff0000; }
p { color: rgb(255,0,0); }
p { color: rgb(100%, 0%, 0%); }
p { color: hsl(0, 100%, 50%); }

/* 50% translucent */
p { color: rgba(255, 0, 0, 0.5); } 
p { color: hsla(0, 100%, 50%, 0.5); }

접근성 고려사항

It is important to ensure that the contrast ratio between the color of the text and the background the text is placed over is high enough that people experiencing low vision conditions will be able to read the content of the page.

Color contrast ratio is determined by comparing the luminosity of the text and background color values. In order to meet current Web Content Accessibility Guidelines (WCAG), a ratio of 4.5:1 is required for text content and 3:1 for larger text such as headings. Large text is defined as 18.66px and bold or larger, or 24px or larger.

명세

Specification Status Comment
CSS Color Module Level 4
The definition of 'color' in that specification.
Working Draft Adds commaless syntaxes for the rgb(), rgba(), hsl(), and hsla() functions. Allows alpha values in rgb() and hsl(), turning rgba() and hsla() into (deprecated) aliases for them.
Adds color keyword rebeccapurple.
Adds 4- and 8-digit hex color values, where the last digit(s) represents the alpha value.
Adds hwb(), device-cmyk(), and color() functions.
CSS Transitions
The definition of 'color' in that specification.
Working Draft Defines color as animatable.
CSS Color Module Level 3
The definition of 'color' in that specification.
Recommendation Deprecates system-colors. Adds SVG colors. Adds the rgba(), hsl(), and hsla() functions.
CSS Level 2 (Revision 1)
The definition of 'color' in that specification.
Recommendation Adds the orange color and the system colors.
CSS Level 1
The definition of 'color' in that specification.
Recommendation Initial definition.
초기값Varies from one browser to another
적용대상all elements. It also applies to ::first-letter and ::first-line.
상속yes
Mediavisual
Computed valueIf the value is translucent, the computed value will be the rgba() corresponding one. If it isn't, it will be the rgb() corresponding one. The transparent keyword maps to rgba(0,0,0,0).
Animation typea color
Canonical orderthe unique non-ambiguous order defined by the formal grammar

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support 1Chrome Android Full support 18Edge Mobile Full support 12Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
Keyword color valuesChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3
Notes
Full support 3
Notes
Notes Internet Explorer 8 and later support gray color keywords spelled with an e (grey, darkgrey, darkslategrey, dimgrey, lightgrey, and lightslategrey). Internet Explorer 3 to Internet Explorer 7 only support the keywords spelled with a (gray, darkgray, darkslategray, dimgray, lightgray, and lightslategray).
Opera Full support 3.5Safari Full support 1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
RGB hexadecimal notation (#RRGGBB, #RGB)Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3.5Safari Full support 1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
RGB functional notation (rgb())Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 3.5Safari Full support 1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
HSL color values (hsl())Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 9Opera Full support 9.5Safari Full support 3.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
Alpha color values (rgba(), hsla())Chrome Full support 1Edge Full support 12Firefox Full support 3IE Full support 9Opera Full support 10Safari Full support 3.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
currentcolorChrome Full support 1Edge ? Firefox Full support 1.5IE Full support 9Opera Full support 9.5Safari Full support 4WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
transparentChrome Full support 1Edge ? Firefox Full support 3IE Full support 9Opera Full support 10Safari Full support 3.1WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
rebeccapurpleChrome Full support 38Edge ? Firefox Full support 33IE Full support 11Opera Full support 25Safari Full support YesWebView Android Full support YesChrome Android ? Edge Mobile ? Firefox Android Full support 33Opera Android ? Safari iOS Full support 8Samsung Internet Android ?
RGBA hexadecimal notation (#RRGGBBAA, #RGBA)Chrome Full support 62
Full support 62
Full support 52
Disabled
Disabled From version 52: this feature is behind the Enable experimental Web Platform features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox Full support 49IE ? Opera Full support 39
Disabled
Full support 39
Disabled
Disabled From version 39: this feature is behind the Enable experimental Web Platform features preference.
Safari Full support 9.1WebView Android ? Chrome Android ? Edge Mobile No support NoFirefox Android ? Opera Android No support NoSafari iOS ? Samsung Internet Android ?
Space-separated functional color notationsChrome Full support 65Edge ? Firefox Full support 52IE ? Opera Full support 52Safari ? WebView Android Full support 65Chrome Android Full support 65Edge Mobile ? Firefox Android Full support 52Opera Android Full support 52Safari iOS ? Samsung Internet Android ?
Allow floats in rgb() and rgba()Chrome Full support 66Edge ? Firefox Full support 52IE ? Opera Full support 53Safari ? WebView Android Full support 66Chrome Android Full support 66Edge Mobile ? Firefox Android Full support 52Opera Android Full support 53Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

같이 보기

문서 태그 및 공헌자

이 페이지의 공헌자: urty5656
최종 변경자: urty5656,