Html font color | SoloLearn: Learn to code for FREE!


Html font color

im aware of how to have a font color. But what is the best way to have a color pattern without having to place the font color code before and after each and every letter?

11/11/2016 3:46:35 AM


5 Answers

New Answer


var textToChange = $("#txt").text(); for(var i = 0; i < textToChange.length; i++) { var newSpan = $("<span />"); .text(textToChange[i]); .css("color", i % 2 == 0 ? "green" : "red"); $("#txt").append(newSpan); } It's something like this.😉


Using CSS you can assign colors to each type of element, class or ID. I strongly suggest you to make the sololearn's CSS course


i will when i finish html, but will it show me how to insert a different color for each letter?


now i understood what you want to do. To achieve this you should use a program language to manipulate the string and wrap each letter inside a HTML element. Then you could dynamically Collor each letter individually


oh ok thats what i was avoiding but ok thanks Carlos