I need to change size, color, and weight of every first letter of each word. I am not talking about Capitalize each first letter. I mean that target first letter and apply s
You should wrap every single word with a tag and use ::first-letter
CSS selector .
Also, note that this selector does not work on inline elements. If you want to use it with an inline element, such a <span>
, make sure you set display:inline-block
(see here for more details: https://stackoverflow.com/a/7631782/11298742)
example :
p span { display: inline-block; font-family: 'Roboto', sans-serif }
p span::first-letter {
color: red;
font-weight: bold;
}
<p><span>Lorem</span> <span>ipsum</span> <span>dolor</span> <span>sit</span> <span>amet</span></p>
AFAIK to achieve this you will have to write the 1st letter in seperate tag like label or div or p tag and apply css to this tag and put rest letters in normal tag
UPDATE: As per your comment if you are getting sentence from text field you will have to make a Javascript that will loop through all words and with the help of substr find the 1st character of each word and appy css by putting it in a tag and keep rest letters outside the tag then replace final output with original text