This is a problem with the span:before
selector, see below.
From https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter
The first letter of an element is not necessarily trivial to identify:
...
Finally, the :: combination before the pseudo-element and the content property can insert some text at the beginning of the element. In this case :: the first letter will correspond to the first letter of this generated content.
If you want the "-" before the capital letter is written in the first letter, you can do the following by changing the structure and css
CSS
span { display:inline-block; color:#66a400; } span#before::before { content:"- "; padding:0 2px; } span#content { text-transform:capitalize; }
HTML
<span id="before"></span><span id="content">my first word</span>
source share