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 / box-sizing

CSS / Reference / box-sizing

box-sizing은 박스의 크기를 어떤 것을 기준으로 계산할지를 정하는 속성입니다. 기본값 : content-box 상속 : No 애니메이션 : No 버전 : CSS Level 3

CSS / Reference / line-height

CSS / Reference / line-height

line-height 속성은 텍스트 줄 간격(줄 높이)을 조절하는 데 사용됩니다. 텍스트의 가독성을 높이고, 디자인적으로 더 일관된 레이아웃을 만들기 위해 자주 사용됩니다. 기본값 : normal 상속 : Yes 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / text-indent

CSS / Reference / text-indent

들여쓰기와 내어쓰기는 text-indent 속성으로 만듭니다. 값이 양수이면 들여쓰기, 값이 음수이면 내어쓰기가 됩니다. 내어쓰기를 할 때는 왼쪽에 여백을 적절히 줍니다.

CSS / Reference / backface-visibility

CSS / Reference / backface-visibility

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

CSS / Reference / text-shadow

CSS / Reference / text-shadow

text-shadow는 글자에 그림자 효과를 주는 속성입니다. 기본값 : none 상속 : Yes 애니메이션 : Yes 버전 : CSS Level 3 박스에 그림자 효과를 주고 싶다면 box-shadow 속성을 사용합니다.

CSS / Reference / font-size

CSS / Reference / font-size

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

CSS / Reference / font-weight

CSS / Reference / font-weight

font-weight 속성은 CSS에서 글꼴의 굵기를 지정하는 데 사용됩니다. 텍스트의 가독성을 높이거나 디자인의 강조점을 표현할 때 유용합니다. 기본값 : normal 상속 : Yes 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / accent-color

CSS / Reference / accent-color

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

CSS / Reference / opacity

CSS / Reference / opacity

opacity로 요소의 투명도를 정할 수 있습니다. 기본값 : 1 상속 : No 애니메이션 : Yes 버전 : CSS Level 3

CSS / Reference / background-clip

CSS / Reference / background-clip

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