스타일 letterSpacing 속성
예시
요소에서 문자 사이의 간격을 15픽셀로 설정합니다.
document.getElementById("demo").style.letterSpacing = "15px";
정의 및 사용
letterSpacing 속성은 텍스트의 문자 사이의 공백을 설정하거나 반환합니다.
팁: 텍스트에서 단어 사이의 간격을 설정하거나 반환하려면 wordSpacing 속성을 사용하십시오.
브라우저 지원
Property | |||||
---|---|---|---|---|---|
letterSpacing | Yes | Yes | Yes | Yes | Yes |
통사론
letterSpacing 속성을 반환합니다.
object.style.letterSpacing
letterSpacing 속성을 설정합니다.
object.style.letterSpacing = "normal|length|initial|inherit"
속성 값
Value | Description |
---|---|
normal | Normal space between characters. This is default |
length | Defines the space in length units. Negative values are allowed |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
기술적 세부 사항
기본값: | 정상 |
---|---|
반환 값: | 텍스트의 문자 사이의 공백을 나타내는 문자열 |
CSS 버전 | CSS1 |
더 많은 예
예시
음수 값 사용:
document.getElementById("demo").style.letterSpacing = "-2px";
예시
요소의 문자 간격을 반환합니다.
alert(document.getElementById("demo").style.letterSpacing);
예시
letterSpacing 속성과 wordSpacing 속성의 차이점:
function changeLetters() {
document.getElementById("demo1").style.letterSpacing = "15px";
}
function changeWords() {
document.getElementById("demo2").style.wordSpacing = "15px";
}
관련 페이지
CSS 튜토리얼: CSS 텍스트
CSS 참조: 문자 간격 속성
❮ 스타일 개체