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 / background-image

CSS / Reference / background-image

개요 background-image는 이미지를 배경으로 사용하게 하는 속성입니다. 기본값 : none 상속 : No 애니메이션 : No 버전 : CSS Level 1 문법 background-image: none | url | initial | inherit none : 이미지를 배경으로 사용하지 않습니다. url : 이미지의 URL을 입력합니다. initial : 기본값으로 설정합니다. inherit : 부모 요소의 속성값을 상속받습니다. 왼쪽 위에서 시작하여 가로 방향과 세로 방향으로 해당 요소를 다 채울 때까지 반복되어 ...

CSS / Reference / background-color

CSS / Reference / background-color

개요 background-color로 배경의 색을 정합니다. 그 색으로 border와 padding을 포함한 영역을 칠합니다. margin 영역은 칠하지 않습니다. 기본값 : transparent 상속 : No 애니메이션 : Yes 버전 : CSS Level 1 문법 background-color: transparent | color | initial | inherit transparent : 배경색이 없습니다. color : 색을 정합니다. initial : 기본값으로 설정합니다. inherit : 부모 요소의 속성값을 상속받습니다. 예제 1 바깥 여백(margin)은 칠하지 않고, 안쪽 여백(padding)은 칠한다는 것을 ...

CSS / Reference / font-style

CSS / Reference / font-style

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

CSS / Reference / text-decoration

CSS / Reference / text-decoration

개요 text-decoration은 선으로 텍스트를 꾸밀 수 있게 해주는 속성입니다. 기본값 : none 상속 : No 애니메이션 : No 버전 : CSS Level 1 문법 text-decoration: none | line-through | overline | underline | initial | inherit none : 선을 만들지 않습니다. line-through : 글자 중간에 선을 만듭니다. overline : 글자 위에 선을 만듭니다. underline : 글자 아래에 선을 만듭니다. initial : 기본값으로 ...

CSS / Reference / accent-color

CSS / Reference / accent-color

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

CSS / Reference / content

CSS / Reference / content

content는 선택한 요소의 앞이나 뒤에 텍스트, 이미지 등을 추가하는 속성입니다. 기본값 : normal 상속 : No 애니메이션 : No 버전 : CSS Level 2

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 / text-align

CSS / Reference / text-align

text-align은 문단 정렬 방식을 정하는 속성입니다. 기본값 : 읽는 방향이 LTR(왼쪽에서 오른쪽)인 경우 left, RTL(오른쪽에서 왼쪽)인 경우 right 상속 : Yes 애니메이션 : No 버전 : CSS Level 1

CSS / Reference / white-space

CSS / Reference / white-space

개요 white-space는 스페이스와 탭, 줄바꿈, 자동줄바꿈을 어떻게 처리할지 정하는 속성입니다. 기본값 : normal 상속 : Yes 애니메이션 : No 버전 : CSS Level 1 문법 white-space: normal | nowrap | pre | pre-wrap | pre-line | initial | inherit normal, nowrap, pre, pre-wrap, pre-line : 아래 표 참고 initial : 기본값으로 설정합니다. inherit : 부모 요소의 속성값을 상속받습니다.   스페이스와 탭1 줄바꿈2 자동 줄바꿈3 normal 병합 병합 O nowrap 병합 병합 X pre 보존 보존 X pre-wrap 보존 보존 O pre-line 병합 보존 O 연속된 스페이스와 탭의 처리 방법입니다. 병합은 1개의 ...

CSS / Reference / background-position

CSS / Reference / background-position

개요 background-position은 배경 이미지의 위치를 정하는 속성입니다. 기본값 : 0% 0% 상속 : No 애니메이션 : Yes 버전 : CSS Level 1 문법 background-position: x-position y-position | initial | inherit x-position y-position : 가로 위치와 세로 위치를 정합니다. initial : 기본값으로 설정합니다. inherit : 부모 요소의 속성값을 상속받습니다. 위치 값으로 사용할 수 있는 것은 다음과 같습니다. 가로 위치 값 : left, center, right, 백분율, 길이 세로 위치 ...