initial-letter CSS property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The initial-letter CSS property sets the size and sink for dropped, raised, and sunken initial letters. This property applies to ::first-letter pseudo-elements and inline-level first children of block containers.

Syntax

css
/* Keyword values */
initial-letter: normal;

/* One value */
initial-letter: 3; /* 3 lines tall, baseline at line 3 */
initial-letter: 1.5; /* 1.5 lines tall, baseline at line 2 */

/* Two values */
initial-letter: 3 2; /* 3 lines tall, baseline at line 2 (raised 1 line) */
initial-letter: 3 1; /* 3 lines tall, baseline unchanged (raised 2 lines) */

/* Global values */
initial-letter: inherit;
initial-letter: initial;
initial-letter: revert;
initial-letter: revert-layer;
initial-letter: unset;

Values

The keyword value normal, or a <number> optionally followed by an <integer>.

normal

No special initial-letter effect. Text behaves as normal.

<number>

Defines the size of the initial letter, in terms of how many lines it occupies. Negative values are not allowed.

<integer>

Defines the number of lines the initial letter should sink when the size of it is given. Values must be greater than zero. If omitted, it duplicates the size value, floored to the nearest positive whole number.

Formal definition

Initial valuenormal
Applies to::first-letter pseudo-elements and inline-level first child of a block container
Inheritedno
Computed valueas specified
Animation typeby computed value type

Formal syntax

initial-letter = 
normal |
<number [1,∞]> <integer [1,∞]> |
<number [1,∞]> && [ drop | raise ]?

<integer> =
<number-token>

Examples

Setting initial letter size

HTML

html
<p class="normal">Initial letter is normal</p>
<p class="onefive">Initial letter occupies 1.5 lines</p>
<p class="three">Initial letter occupies 3 lines</p>

CSS

css
.normal::first-letter {
  -webkit-initial-letter: normal;
  initial-letter: normal;
}

.onefive::first-letter {
  -webkit-initial-letter: 1.5;
  initial-letter: 1.5;
}

.three::first-letter {
  -webkit-initial-letter: 3;
  initial-letter: 3;
}

p {
  outline: 1px dashed red;
}

Result

Setting the sink value

In this example, all the initial letters are the same size, but with different sink values.

HTML

html
<p class="four">Initial letter: Sink value = 4</p>
<p class="same">Initial letter: Sink value not declared (same as size)</p>
<p class="two">Initial letter: Sink value = 2</p>
<p class="one">Initial letter: Sink value = 1</p>

CSS

css
.four::first-letter {
  -webkit-initial-letter: 3 4;
  initial-letter: 3 4;
}

.same::first-letter {
  -webkit-initial-letter: 3;
  initial-letter: 3;
}

.two::first-letter {
  -webkit-initial-letter: 3 2;
  initial-letter: 3 2;
}

.one::first-letter {
  -webkit-initial-letter: 3 1;
  initial-letter: 3 1;
}

p {
  outline: 1px dashed red;
}

Result

Specifications

Specification
CSS Inline Layout Module Level 3
# sizing-drop-initials

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
initial-letter
Chrome – Full support
Chrome 110 (Release date: 2023-02-07)
footnote Full support
Edge – Full support
Edge 110 (Release date: 2023-02-09)
footnote Full support
Firefox – No support
Firefox
footnote
footnote See bug 1223880
Opera – Full support
Opera 96 (Release date: 2023-02-22)
footnote Full support
Safari – Full support
Safari 9 (Release date: 2015-09-30)
prefix , footnote
prefix Implemented with the vendor prefix: -webkit-
footnote See bug 229090 for the unprefixed property.
Chrome Android – Full support
Chrome Android 110 (Release date: 2023-02-07)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote
footnote See bug 1223880
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 9 (Release date: 2015-09-16)
prefix
footnote Partial support
prefix Implemented with the vendor prefix: -webkit-
footnote See bug 229090 for the unprefixed property.
footnote Does not support decimal values. See bug 296785.
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 110 (Release date: 2023-02-07)
footnote Full support
WebView on iOS – Partial support
WebView on iOS 9 (Release date: 2015-09-16)
prefix
footnote Partial support
prefix Implemented with the vendor prefix: -webkit-
footnote See bug 229090 for the unprefixed property.
footnote Does not support decimal values. See bug 296785.
normal
Chrome – Full support
Chrome 110 (Release date: 2023-02-07)
footnote Full support
Edge – Full support
Edge 110 (Release date: 2023-02-09)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 96 (Release date: 2023-02-22)
footnote Full support
Safari – Full support
Safari 9 (Release date: 2015-09-30)
footnote Full support
Chrome Android – Full support
Chrome Android 110 (Release date: 2023-02-07)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 9 (Release date: 2015-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 110 (Release date: 2023-02-07)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Requires a vendor prefix or different name for use.

See also