Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Lets say, I have word 'Test'. Is it possible to make lets say, first letter(T) red, second(e) - green and bold and last(t) - just bold? I can break word on symbols and apply different styles but maybe I can do it without splitting?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
879 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can apply a specific colour, and style, to the :first-letter of an element, but beyond that: no, this isn't possible without JavaScript; unless each letter (or pair of letters) is wrapped in its own element.

div {
    color: black;
}

div:first-letter {
    color: red;
}

JS Fiddle demo, using :first-letter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...