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 style according to my choice. : Click Here to see example about which i am talking.
Asked
Active
Viewed 1.3k times
8
-
1This is a duplicate: https://stackoverflow.com/questions/7440572/css-bold-first-word – Derek Brown Oct 20 '17 at 16:42
-
1Not in CSS. Possible in JS however. Agree with duplicate – Francisco Oct 20 '17 at 16:51
-
2@DerekBrown look at my question and example first. I don't need targeting the first letter of a paragraph. I need target first letter of each word in a sentence. your provided link is not my solution, I have checked this before – Shakil Ahmad Oct 21 '17 at 08:01
1 Answers
12
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>