+ 1

How to color eache character of a text?

I wanted to color each character of an <h1> with random colors but I don't know how to assign those colors to the <h1> tag.

24th Mar 2019, 1:00 AM
oh Common
oh Common - avatar
6 Réponses
+ 6
Use span to enclose each character https://code.sololearn.com/WwLpwJetzg3f/?ref=app
24th Mar 2019, 1:03 AM
Gordon
Gordon - avatar
+ 3
You can try first, and check with this (rendering the letters with JavaScript) : https://code.sololearn.com/WM0bz2TRKJOr/?ref=app
24th Mar 2019, 2:22 AM
Gordon
Gordon - avatar
+ 3
And also, this (adding random color to each letter by JavaScript) : https://code.sololearn.com/WNphMYDZnoEJ/?ref=app
24th Mar 2019, 2:36 AM
Gordon
Gordon - avatar
+ 2
You'll need to use createElement() and appendChild() https://code.sololearn.com/W0dEL7sP29qH/?ref=app
24th Mar 2019, 2:11 AM
Gordon
Gordon - avatar
+ 1
Gordon thank you again! I learned so if I implement this on a JavaScript I would use a for loop in the text of the title and use span tag in each character of it, right?
24th Mar 2019, 1:25 AM
oh Common
oh Common - avatar
+ 1
Gordon ok, thank you!
24th Mar 2019, 2:13 AM
oh Common
oh Common - avatar