CSS / Reference / word-wrap

개요

word-wrap은 띄어쓰기가 없는 긴 단어를 어떻게 처리할지 정하는 속성입니다.

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

문법

word-wrap: normal | break-word | initial | inherit
  • normal : break point에서 줄바꿈합니다.
  • break-word : 요소의 경계에서 break point가 아니어도 줄바꿈을 합니다.
  • initial : 기본값으로 설정합니다.
  • inherit : 부모 요소의 속성값을 상속받습니다.

word-break 속성의 값이 keep-all이면 단어가, break-all이면 글자가 break-point입니다.

예제

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>CSS</title>
    <style>
      p {
        width: 400px;
        padding: 10px;
        background-color: #dddddd;
      }
      .a {
        word-break: keep-all;
        word-wrap: normal;
      }
      .b {
        word-break: keep-all;
        word-wrap: break-word;
      }
      .c {
        word-break: break-all;
        word-wrap: normal;
      }
      .d {
        word-break: break-all;
        word-wrap: break-word;
      }
    </style>
  </head>
  <body>
    <p class="a">loremipsumdolorloremipsumdolorloremipsumdolorloremipsumdolorloremipsumdolor</p>
    <p class="b">loremipsumdolorloremipsumdolorloremipsumdolorloremipsumdolorloremipsumdolor</p>
    <p class="c">loremipsumdolorloremipsumdolorloremipsumdolorloremipsumdolorloremipsumdolor</p>
    <p class="d">loremipsumdolorloremipsumdolorloremipsumdolorloremipsumdolorloremipsumdolor</p>
  </body>
</html>

같은 카테고리의 다른 글
CSS / Reference / align-content

CSS / Reference / align-content

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

CSS / Reference / background-size

CSS / Reference / background-size

background-size는 배경 이미지의 가로 크기와 세로 크기를 정하는 속성입니다. 기본값 : auto 상속 : No 애니메이션 : Yes 버전 : CSS Level 3

CSS / Reference / white-space

CSS / Reference / white-space

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

CSS / Reference / calc()

CSS / Reference / calc()

calc()는 괄호 안의 식을 계산한 결과를 속성값으로 사용하게 해주는 함수입니다. 예를 들어 다음은 는 글자 크기를 20px로 설정합니다. font-size: calc( 10px + 10px );

CSS / Reference / background-repeat

CSS / Reference / background-repeat

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

CSS / Reference / background-position

CSS / Reference / background-position

background-position은 배경 이미지의 위치를 정하는 속성입니다. 기본값 : 0% 0% 상속 : No 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / text-shadow

CSS / Reference / text-shadow

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

CSS / Reference / empty-cells

CSS / Reference / empty-cells

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

CSS / Reference / font-size

CSS / Reference / font-size

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

CSS / Reference / text-indent

CSS / Reference / text-indent

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