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 / white-space

CSS / Reference / white-space

white-space는 스페이스와 탭, 줄바꿈, 자동줄바꿈을 어떻게 처리할지 정하는 속성입니다. 기본값 : normal 상속 : Yes 애니메이션 : No 버전 : CSS Level 1

CSS / Reference / background-repeat

CSS / Reference / background-repeat

background-repeat는 배경 이미지의 반복 여부와 반복 방향을 정하는 속성입니다. 기본값 : repeat 상속 : No 애니메이션 : No 버전 : CSS Level 1

CSS / Reference / font-style

CSS / Reference / font-style

font-style은 글자 모양을 정하는 속성으로, 기울임 여부를 정합니다. 기본값 : normal 상속 : Yes 애니메이션 : No 버전 : CSS Level 1

CSS / Reference / backface-visibility

CSS / Reference / backface-visibility

backface-visibility는 요소의 뒷쪽에서 앞면이 보이게 할지 정하는 속성입니다. 기본값 : visible 상속 : No 애니메이션 : No 버전 : CSS Level 3

CSS / Reference / empty-cells

CSS / Reference / empty-cells

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

CSS / Reference / word-break

CSS / Reference / word-break

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

CSS / Reference / tab-size

CSS / Reference / tab-size

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

CSS / Reference / border-width

CSS / Reference / border-width

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

CSS / Reference / align-content

CSS / Reference / align-content

flex-wrap 속성의 값이 wrap인 경우, 아이템들의 가로폭의 합이 콘테이너의 가로폭을 넘어가면 아이템이 다음 줄로 내려갑니다. 이때 여러 줄이 되어버린 아이템들의 정렬을 어떻게 할지 정하는 속성이 align-content입니다.

CSS / Reference / background-clip

CSS / Reference / background-clip

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