<h2>hello world</h2>
Here, i want to styling first word "hello" without using any span or b tag or any JavaScript. just using style like h2:first-word{color:red}
.
Is it possible? If possible how can i solve it?
<h2>hello world</h2>
Here, i want to styling first word "hello" without using any span or b tag or any JavaScript. just using style like h2:first-word{color:red}
.
Is it possible? If possible how can i solve it?
You can't because there's no :first-word
selector, only :first-letter
and :first-line
. You'll need insert span dynamically with JS if you don't control original HTML.
As far as i know it is not possible with pure css. There are some solutions with javascript.
Library: nthEverything Examples: Examples with ::first-word