Definition and Usage
The letter-spacing property specifies the spacing between characters in text.
It allows you to increase or decrease the space between characters.
For example, applying letter-spacing: 2px increases the space between characters by 2px.
Conversely, applying letter-spacing: -2px decreases the space between characters by 2px.
Basic Example
This property specifies the spacing between characters.
The syntax for the letter-spacing property is as follows.
Syntax
/* Keyword values */
letter-spacing: normal;
/* <length> values */
letter-spacing: 0; /* Same as normal */
letter-spacing: 2px;
letter-spacing: -2px;
letter-spacing: 1em;
letter-spacing: -0.15em;
letter-spacing: 1rem;
letter-spacing: -0.11rem;
/* Percentage (%) values: Supported only in some browsers */
letter-spacing: -50%;
letter-spacing: 200%;
/* Global values */
letter-spacing: inherit;
letter-spacing: initial;
letter-spacing: revert;
letter-spacing: revert-layer;
letter-spacing: unset;
Formal Syntax
selector {
letter-spacing: /* value */
}
Formal Definition
| Initial value | normal |
|---|---|
| Applies to | all elements |
| Inherited | yes |
| Animatable | yes |
Values
normal |
The normal character spacing of the current font.
Calculated as 0 in length units. |
|---|---|
length |
A length value. (Positive, 0, and negative values are allowed.) |
percentage |
A percentage (%) value relative to the font size of the applied text.
Supported only in some browsers. See Browser Compatibility. |
Examples
<h3 class="normal">letter-spacing Property Example</h3>
<p class="em-tight">This property specifies the spacing between characters.</p>
<p class="em-wide">This property specifies the spacing between characters.</p>
<p class="px-tight">This property specifies the spacing between characters.</p>
<p class="px-wide">This property specifies the spacing between characters.</p>
.normal {
letter-spacing: normal; /* Same as 0 */
}
.em-tight {
letter-spacing: -0.05em;
}
.em-wide {
letter-spacing: 0.5em;
}
.px-tight {
letter-spacing: -2px;
}
.px-wide {
letter-spacing:5px;
}
letter-spacing Property Example
This property specifies the spacing between characters.
This property specifies the spacing between characters.
This property specifies the spacing between characters.
This property specifies the spacing between characters.
Things to Keep in Mind
There are two things to keep in mind when using the letter-spacing property.
text-align: end Can Cause Spacing at the End Edge of a Line
The specification states that the letter-spacing property must not apply character spacing at the beginning of a line, but it does not define the behavior at the end of a line.
In most browsers, text is always aligned at the beginning of a line, but the end of a line is not aligned in the same way.
Let's look at the following example.
p {
letter-spacing: 1em;
background-color: orange;
}
<p style="text-align: start;">abc</p>
abc
In the example above, the text with text-align: start applied does not have additional spacing at the beginning (left) edge of the line.
However, in the following example, major browsers show spacing at the end (right) edge of the line when text-align: end is applied.
p {
letter-spacing: 1em;
background-color: orange;
}
<p style="text-align: end;">abc</p>
abc
In this case, you should consider that unwanted spacing may be applied, resulting in an unintended appearance.
Accessibility Considerations
If the spacing between characters is set too narrow or too wide using the letter-spacing property, users may have difficulty reading text with this style applied.
Adjusting the spacing between characters using the letter-spacing property is very important for styling, but it needs to be adjusted appropriately depending on the situation.
If the spacing between characters is set too narrow or too wide, users may have difficulty reading text with this style applied.
If the spacing between characters is set too narrow or too wide, users may have difficulty reading text with this style applied.
Browser Compatibility
Last updated:
| Property and Value |
Desktop Chrome
|
Desktop Edge
|
Desktop Firefox
|
Safari
|
|---|---|---|---|---|
letter-spacing
|
1 | 12 | 12 | 1 |
percentage values |
145 | 145 | 45 | 7 |
The percentage value is not supported in Samsung Internet and Opera Mobile.
Specifications
| Specification | |
|---|---|
letter-spacing
|
CSS Text Module Level 4 #letter-spacing-property |
References
See Also
- CSS font-kerning Property – A Complete Guide
- CSS word-spacing Property – Proper Understanding and Usage
- CSS word-break Property – Rules for Breaking Words When Text Wraps
- CSS text-overflow Property – Specifying a Single-Line Text Ellipsis (…)
- CSS -webkit-line-clamp Property – Setting a Multi-Line Text Ellipsis (…)
- CSS text-align Property – Setting Horizontal Alignment for Text and Inline Content
- CSS writing-mode Property – Setting Text in Vertical Writing Mode
- CSS white-space Property – Specifies White Space and Soft Wrapping