CSS / Reference / accent-color

개요

accent-color는 HTML의 폼 요소에 사용되는 강조 색상을 정하는 속성입니다. 기본적으로 브라우저는 사용자 인터페이스 요소에 특정한 시스템 색상을 사용하지만, accent-color를 사용하면 이러한 요소들의 강조 색상을 커스터마이즈할 수 있습니다.

다음 요소에 적용할 수 있습니다.

  • <input type="checkbox">
  • <input type="radio">
  • <input type="range">
  • <progress>

문법

accent-color: auto | color | initial | inherit
  • auto : 기본값으로, 브라우저가 색을 정합니다.
  • color : 색을 정합니다.
  • initial : 기본값으로 설정합니다.
  • inherit : 부모 요소의 속성값을 상속 받습니다.

예제 - input checkbox

체크박스를 선택하면 녹색이 됩니다.

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>CSS</title>
    <style type="text/css">
      body {
        font-family: Consolas;
        font-style: italic;
      }
      input[type=checkbox] {
        accent-color: green;
      }
    </style>
  </head>
  <body>
    <p>
      <input type="checkbox" id="apple"> <label for="apple">Apple</label>
      <input type="checkbox" id="banana"> <label for="banana">Banana</label>
    </p>
  </body>
</html>

예제 - input radio

라디오 버튼을 선택하면 빨간색이 됩니다.

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>CSS</title>
    <style type="text/css">
      body {
        font-family: Consolas;
        font-style: italic;
      }
      input[type=radio] {
        accent-color: red;
      }
    </style>
  </head>
  <body>
    <p>
      <label><input type="radio" name="fruit" value="apple"> Apple</label>
      <label><input type="radio" name="fruit" value="banana"> Banana</label>
    </p>
  </body>
</html>

예제 - input range

슬라이더의 색이 녹색이 됩니다.

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>CSS</title>
    <style type="text/css">
      body {
        font-family: Consolas;
        font-style: italic;
      }
      input[type=range] {
        accent-color: green;
      }
    </style>
  </head>
  <body>
    <p>
      <input type="range" min="0" max="100" value="50">
    </p>
  </body>
</html>

예제 - progress

진행 상태를 나타내는 바의 색이 빨간색이 됩니다.

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>CSS</title>
    <style type="text/css">
      body {
        font-family: Consolas;
        font-style: italic;
      }
      progress {
        accent-color: red;
      }
    </style>
  </head>
  <body>
    <p>
      <progress max="100" value="70"></progress>
    </p>
  </body>
</html>

예제 - input range와 progress의 색

타입이 range인 input 요소와 progress 요소는 accent-color에 따라 나머지 부분의 색이 달라집니다.

예를 들어 accent-color를 cyan으로 하면 나머지 부분의 색이 진해집니다.

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>CSS</title>
    <style type="text/css">
      body {
        font-family: Consolas;
        font-style: italic;
      }
      .a input[type=range], .a progress {
        accent-color: blue;
      }
      .b input[type=range], .b progress {
        accent-color: cyan;
      }
    </style>
  </head>
  <body>
    <p>
      <input type="range" min="0" max="100" value="50"><br>
      <progress max="100" value="50"></progress>
    </p>
    <p class="a">
      <input type="range" min="0" max="100" value="50"><br>
      <progress max="100" value="50"></progress>
    </p>
    <p class="b">
      <input type="range" min="0" max="100" value="50"><br>
      <progress max="100" value="50"></progress>
    </p>
  </body>
</html>

같은 카테고리의 다른 글
CSS / Reference / border-style

CSS / Reference / border-style

border-style은 테두리(border)의 모양을 정하는 속성으로, 다음 속성의 단축 속성입니다. border-top-style border-right-style border-bottom-style border-left-style

CSS / Reference / quotes

CSS / Reference / quotes

quotes는 q 태그로 만든 인용문을 감싸는 큰따옴표를 다른 기호 또는 문자로 바꿔주는 속성입니다. 기본값 : 큰따옴표 상속 : Yes 애니메이션 : No 버전 : CSS Level 2

CSS / Reference / background-size

CSS / Reference / background-size

background-size는 배경 이미지의 가로 크기와 세로 크기를 정하는 속성입니다. 기본값 : auto 상속 : No 애니메이션 : Yes 버전 : CSS Level 3

CSS / Reference / box-shadow

CSS / Reference / box-shadow

box-shadow는 선택한 요소에 그림자 효과를 만들어주는 속성입니다. 기본값 : none 상속 : No 애니메이션 : Yes 버전 : CSS Level 3 글자에 그림자 효과를 주고 싶다면 text-shadow 속성을 사용합니다.

CSS / Reference / font-variant

CSS / Reference / font-variant

font-variant는 소문자를 작은 대문자, 즉 소문자 크기의 대문자로 바꾸는 속성입니다. 따라서 한글에서는 의미 없는 속성입니다. 기본값 : normal 상속 : Yes 애니메이션 : No 버전 : CSS Level 1

CSS / Reference / font-size

CSS / Reference / font-size

font-size는 글자 크기를 정하는 속성입니다. 기본값 : medium 상속 : Yes 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / background-clip

CSS / Reference / background-clip

HTML 요소는 박스(box)로 이루어져 있습니다. 배경 이미지나 배경색을 그 박스 중 어디에 넣을 지 정하는 속성이 background-clip입니다. 기본값 : border-box 상속 : No 애니메이션 : No 버전 : CSS Level 3

CSS / Reference / word-break

CSS / Reference / word-break

word-break는 줄바꿈을 할 때 단어 기준으로 할 지 글자 기준으로 할 지 정하는 속성입니다. 기본값 : normal 상속 : Yes 애니메이션 : No 버전 : CSS Level 3

CSS / Reference / empty-cells

CSS / Reference / empty-cells

empty-cells은 표(table)에서 빈 셀의 테두리를 표시할지 말지는 정하는 속성입니다. 기본값 : show 상속 : Yes 애니메이션 : No 버전 : CSS Level 2

CSS / Reference / tab-size

CSS / Reference / tab-size

HTML은 탭을 연속하여 여러 개 넣어도 하나의 공백으로 인식합니다. 하지만 pre 태그를 이용하면 입력된 그대로 출력할 수 있습니다. 기본적으로 하나의 탭을 8개의 공백으로 인식합니다. 이 탭 크기를 조정하는 속성이 tab-size입니다.