Is there a way to select specific words in a paragraph using pure CSS.
For example, if I wanted to style every word “apple” in a paragraph red, and every word “orange” in a paragraph orange, is there way to do that without PHP or javascript using pure CSS?
CSS works by styling elements based on a set of rules.
Unless the text is in element by itself with something that will differentiate it from other elements it’s not possible.
What you use to differentiate it is up to you.
Classes are the most obvious method, such as <span class="apple">Apple</span> but there are others, some more specific..like ID (that can only be used once) or broader, like data-attributes.
Author
Posts
Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘CSS’ is closed to new topics and replies.