CSS / Reference / accent-color

개요

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 / empty-cells

CSS / Reference / empty-cells

개요 empty-cells은 표(table)에서 빈 셀의 테두리를 표시할지 말지는 정하는 속성입니다. 기본값 : show 상속 : Yes 애니메이션 : No 버전 : CSS Level 2 문법 empty-cells: show | hide | initial | inherit show : 빈 셀의 테두리를 보여줍니다. hide : 빈 셀의 테두리를 숨김니다. initial : 기본값으로 설정합니다. inherit : 부모 요소의 속성값을 상속받습니다. 예제 첫 번째 표는 빈 셀의 테두리를 표시합니다. 두 ...

CSS / Reference / calc()

CSS / Reference / calc()

개요 calc()는 괄호 안의 식을 계산한 결과를 속성값으로 사용하게 해주는 함수입니다. 예를 들어 다음은 는 글자 크기를 20px로 설정합니다. font-size: calc( 10px + 10px ); 문법 연산자 +는 덧셈, -는 뺄셈, *는 곱셈, /는 나눗셈입니다. 곱셈과 나눗셈의 좌우에는 공백이 없어도 됩니다. 하지만, 덧셈과 뺄셈의 좌우에는 공백이 있어야 합니다. 계산 순서 왼쪽에서 오른쪽으로 계산합니다. 곱셈과 나눗셈을 먼저 하고, 덧셈과 뺄셈은 ...

CSS / Reference / align-content

CSS / Reference / align-content

개요 flex-wrap 속성의 값이 wrap인 경우, 아이템들의 가로폭의 합이 콘테이너의 가로폭을 넘어가면 아이템이 다음 줄로 내려갑니다. 이때 여러 줄이 되어버린 아이템들의 정렬을 어떻게 할지 정하는 속성이 align-content입니다. 문법 align-content: stretch | center | flex-start | flex-end | space-between | space-around | space-evenly | initial | inherit stretch : 기본값으로, 높이를 꽉 채웁니다. flex-start : 위쪽부터 ...

CSS / Reference / letter-spacing, word-spacing

CSS / Reference / letter-spacing, word-spacing

개요 글자 사이의 간격은 letter-spacing으로, 단어 사이의 간격은 word-spacing으로 정합니다. 값이 커지면 간격이 커집니다. 값에는 음수를 넣을 수 있습니다. 음수를 값으로 하는 경우 글자가 겹칠 수 있습니다. 예제 아래는 값의 변화에 따른 간격의 변화를 보여주는 예제입니다. 글자 사이의 간격을 변화시키면 단어 사이의 간격도 변합니다. 단어 사이의 간격을 변화시켜도 글자 사이의 간격은 변하지 않습니다. <!doctype html> <html lang="ko"> <head> ...

CSS / Reference / line-height

CSS / Reference / line-height

개요 line-height는 줄 높이를 정하는 속성입니다. 기본값 : normal 상속 : Yes 애니메이션 : Yes 버전 : CSS Level 1 문법 line-height: normal | length | number | percentage | initial | inherit normal : 웹브라우저에서 정한 기본값입니다. 보통 1.2입니다. length : 길이로 줄 높이를 정합니다. number : 글자 크기의 몇 배인지로 줄 높이를 정합니다.  percentage : 글자 크기의 몇 %로 줄 ...

CSS / Reference / word-break

CSS / Reference / word-break

개요 word-break는 줄바꿈을 할 때 단어 기준으로 할 지 글자 기준으로 할 지 정하는 속성입니다. 기본값 : normal 상속 : Yes 애니메이션 : No 버전 : CSS Level 3 문법 word-break: normal | break-all | keep-all | initial | inherit; normal : CJK 문자는 글자 기준으로, CJK 이외의 문자는 단어 기준으로 줄바꿈합니다. break-all : 글자 기준으로 줄바꿈합니다. keep-all : 단어 ...

CSS / Reference / background-attachment

CSS / Reference / background-attachment

개요 background-attachment는 배경 이미지의 스크롤 여부를 정하는 속성입니다. 기본값 : scroll 상속 : No 애니메이션 : No 버전 : CSS Level 1 문법 background-attachment: scroll | fixed | local | initial | inherit scroll : 선택한 요소와 같이 움직입니다. 내용을 스크롤하면 배경 이미지는 스크롤되지 않습니다. fixed : 움직이지 않습니다. local : 선택한 요소와 같이 움직입니다. 내용을 스크롤하면 배경 이미지도 스크롤됩니다. initial : ...

CSS / Reference / quotes

CSS / Reference / quotes

개요 quotes는 q 태그로 만든 인용문을 감싸는 큰따옴표를 다른 기호 또는 문자로 바꿔주는 속성입니다. 기본값 : 큰따옴표 상속 : Yes 애니메이션 : No 버전 : CSS Level 2 문법 quotes: none | string | initial | inherit none : 인용 부호를 없앱니다. string : 인용 부호로 사용할 값을 넣습니다. initial : 기본값으로 설정합니다. inherit : 부모 요소의 속성값을 상속받습니다. 예제 q 태그는 문단 ...

CSS / Reference / font-style

CSS / Reference / font-style

개요 font-style은 글자 모양을 정하는 속성으로, 기울임 여부를 정합니다. 기본값 : normal 상속 : Yes 애니메이션 : No 버전 : CSS Level 1 문법 font-style: normal | italic | oblique | initial | inherit normal : 보통 모양입니다. italic : 기울임꼴입니다. oblique : 기울임꼴입니다. initial : 기본값으로 설정합니다. inherit : 부모 요소의 속성값을 상속받습니다. italic은 필기체 느낌으로 기울이고, oblique는 보통 모양을 그대로 기울입니다. 아래의 이미지에서 두번째 줄이 italic, 세번째 ...

CSS / Reference / border-width

CSS / Reference / border-width

개요 border-width은 테두리(border)의 두께를 정하는 속성으로, 다음 속성의 단축 속성입니다. border-top-width border-right-width border-bottom-width border-left-width 문법 border-width: medium | thin | thick | length | initial | inherit; initial : 기본값으로 설정합니다. 기본값은 medium입니다. inherit : 부모 요소의 속성값을 상속받습니다. 속성값은 한 개에서 네 개까지 정할 수 있습니다. 다음은 모든 테두리의 두께를 xx로 만듭니다. border-width: xx 다음은 위쪽과 아래쪽 테두리의 두께는 xx로, 왼쪽와 오른쪽의 ...