Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I select text except for the first letter?

I know that ::first-letter selects the first letter of a block-level element.

How can I select all text except the first letter?

I tried :not(::first-letter) but that didn't select anything.

like image 775
joews Avatar asked Feb 12 '16 14:02

joews


1 Answers

:not can only be applied to simple selectors. Pseudo-elements aren't simple selectors, so you can't invert them.

You could apply the "non-first letter" styles to all of the text and reverse them for the first letter.

For example:

p {
  color: red;
  text-transform: uppercase;
}

p::first-letter {
  color: black;
  text-transform: none;
}
<p>red capitals except the first letter.</p>
like image 112
joews Avatar answered Sep 21 '22 01:09

joews