CSS / Reference / border-spacing

개요

border-spacing은 표의 테두리와 셀의 테두리 사이의 간격을 정하는 속성입니다.

  • 기본값 : 2px
  • 상속 : Yes
  • 애니메이션 : No
  • 버전 : CSS Level 2

border-spacing은 border-collapse의 값이 separate일 때만 적용됩니다.

문법

border-spacing: length | initial | inherit
  • length : 길이를 입력합니다. 값이 한개면 모든 간격에 같은 값을 사용하고, 값이 두개면 첫번째 값은 좌우, 두번째 값은 상하의 간격으로 사용합니다.
  • initial : 기본값으로 설정합니다.
  • inherit : 부모 요소의 속성값을 상속받습니다.

예제

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>CSS</title>
    <style>
      table {
        width: 100%;
        border: 1px solid #333333;
      }
      td {
        padding: 10px;
        border: 1px solid #333333;
      }
      .a {
        border-spacing: 0px;
      }
      .b {
        border-spacing: 5px;
      }
      .c {
        border-spacing: 10px;
      }
      .d {
        border-spacing: 5px 10px;
      }
    </style>
  </head>
  <body>
    <h1>Border Spacing : Default</h1>
    <table>
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
    </table>
    <h1>Border Spacing : 0px</h1>
    <table class="a">
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
    </table>
    <h1>Border Spacing : 5px</h1>
    <table class="b">
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
    </table>
    <h1>Border Spacing : 10px</h1>
    <table class="c">
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
    </table>
    <h1>Border Spacing : 5px 10px</h1>
    <table class="d">
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
      <tr>
        <td>Lorem</td><td>Ipsum</td><td>Dolor</td>
      </tr>
    </table>
  </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 / accent-color

CSS / Reference / accent-color

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

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 / line-height

CSS / Reference / line-height

line-height 속성은 텍스트 줄 간격(줄 높이)을 조절하는 데 사용됩니다. 텍스트의 가독성을 높이고, 디자인적으로 더 일관된 레이아웃을 만들기 위해 자주 사용됩니다. 기본값 : normal 상속 : 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 / text-indent

CSS / Reference / text-indent

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

CSS / Reference / font-weight

CSS / Reference / font-weight

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

CSS / Reference / font-style

CSS / Reference / font-style

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

CSS / Reference / background-color

CSS / Reference / background-color

background-color로 배경의 색을 정합니다. 그 색으로 border와 padding을 포함한 영역을 칠합니다. margin 영역은 칠하지 않습니다. 기본값 : transparent 상속 : No 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / font-size

CSS / Reference / font-size

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