スタイル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リファレンス:文字間隔プロパティ
❮スタイルオブジェクト