::first-letter does not count `@` and apply css in 2 letters

59 Views Asked by At

while playing around ::first-letter

when string start with @ then it color 2 letters.

 footer {
 color: mediumseagreen;
 font-size: 2rem;
 font-style: italic;
}
footer::first-letter { color: purple; }
<footer>@xyz</footer>
<footer>xyz</footer>

is this right behavior?

1

There are 1 best solutions below

0
Daniel Beck On BEST ANSWER

Per MDN,

Punctuation that precedes or immediately follows the first letter is included in the match. Punctuation includes any Unicode character defined in the open (Ps), close (Pe), initial quote (Pi), final quote (Pf), and other punctuation (Po) classes.

The @ character is part of the "Other Punctuation" category, so it is correct for @x to be highlighted in your first example.