Hi guys!
I’m in middle of creating a colorful webpage and I know the code’s messy but before I continue, I need to figure out away to make each letter in the text a different color without using 100reds of span elements and selectors because I run out of names.
Ex:
No problem. It is definitely easier than coloring each letter.
If you add enough color stops with duplicated colors and give percentages to each letter as needed it might look like what you want. But that would be a lot more work as well and it would have to be done for each block of text. So it wouldn’t be any easier, likely the opposite.
First: If you go to the settings, under “HTML preprocessor”, you can use a templating language for the HTML which will let you use loops. With that you can generate the HTML in a loop rather than either writing it manually or using JS. This doesn’t do anything different to what you’re doing now, but it’s a lot less markup to write (you could also use Sass as the CSS preprocessor to loop over classes).
Second: You won’t have control over individual colours, but you can use a mask + a gradient background on the text to give a very similar effect (this will only really work visually if you only have one line of text).
Third: more involved but much easier to use once you’ve done it:l – If you were ok with each letter being the same colour (eg all "A"s one colour, "B"s another colour and so on), then you could use birdfont to edit a font with different colours for each letter. Then you can just use that font, it’ll already be coloured so you wouldn’t have to wrap anything in the HTML or apply any CSS for the colours.