CSS

字母间距 | letter-spacing

字母间距

letter-spacing CSS属性指定的文本字符之间的间距行为。

/* <length> values */ letter-spacing: 0.3em; letter-spacing: 3px; letter-spacing: .3px; /* Keyword values */ letter-spacing: normal; /* Global values */ letter-spacing: inherit; letter-spacing: initial; letter-spacing: unset;

初始值 normal
适用于所有元素。它也适用于:: first-letter和:: first-line。
遗传
媒体 visual
计算值由绝对长度或关键字法线组成的最佳值
动画类型长度
规范的顺序形式语法定义的独特的非模糊顺序

语法

normal当前字体的正常字母间距。与值0不同,此值允许用户代理更改字符之间的空格以便对齐文本。

形式语法

normal | <length>

实例

HTML

<p class="first-example"> letter spacing </p> <p class="second-example"> letter spacing </p> <p class="third-example"> letter spacing </p> <p class="fourth-example"> letter spacing </p>

CSS

.first-example { letter-spacing: 0.4em; } .second-example { letter-spacing: 1em; } .third-example { letter-spacing: -0.05em; } .fourth-example { letter-spacing: 6px; }

规范

SpecificationStatusComment
CSS Text Module Level 3The definition of 'letter-spacing' in that specification.Working DraftNo change.
CSS TransitionsThe definition of 'letter-spacing' in that specification.Working DraftDefines letter-spacing as animatable.
CSS Level 2 (Revision 1)The definition of 'letter-spacing' in that specification.RecommendationNo change.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'letter-spacing' in that specification.RecommendationInitial SVG definition.
CSS Level 1The definition of 'letter-spacing' in that specification.RecommendationInitial definition.

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
HTML support1.0(Yes)1.0 (1.7 or earlier)4.03.51.0 (85)
SVG support(Yes)?No support (bug 371787)?(Yes)(Yes)

FeatureAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
HTML support?(Yes)????
SVG support??????