Really new to HTML and CSS and all this basically,I have a header on my website, but I want each letter to be a specific colour I say such as green and blue, how would I do this on CSS?
Really new to HTML and CSS and all this basically,I have a header on my website, but I want each letter to be a specific colour I say such as green and blue, how would I do this on CSS?
You might want to take a look here: http://www.w3schools.com/css/default.asp
Are you talking about them alternating like this:
Merry Christmas
or like the words like this:
Merry Christmas
I know you could just have 2 classes and then have each letter in it's own class if it is the first one or each word if the second but that might be a bit messy, probably a better way to do it.
Like the first one,You might want to take a look here: http://www.w3schools.com/css/default.asp
Are you talking about them alternating like this:
Merry Christmas
or like the words like this:
Merry Christmas
I know you could just have 2 classes and then have each letter in it's own class if it is the first one or each word if the second but that might be a bit messy, probably a better way to do it.![]()
The use CSS to style the classesHTML Code:<span class="red">Letter</span> <span class="green">Letter</span>
or...
The second method requires no css, but it's a more tacky way in my opinion.HTML Code:<span style="color: Red">Letter</span> <span style="color: Green">Letter</span>
Last edited by lRhyss; 20-12-2013 at 05:45 PM.
Or you can do something like this. http://jsfiddle.net/sJTTG/
HTML Code:<div class="text"> <span>H</span> <span>E</span> <span>L</span> <span>L</span> <span>O</span> </div>HTML Code:.text span { color: blue; } .text span:nth-child(odd) { color: red; }
Yeh i like the habbox codes but i dunno what they are :/
They're probably using javascript.
http://jsfiddle.net/xpZqs/HTML Code:function alternate(colorpair) { if(colorpair.indexOf('|') == -1) return; var el = document.getElementById('alternator'); colorpair = colorpair.split('|'); var letters = el.innerHTML.replace(/^\s*|\s*$/g,''). /*strip leading/trailing spaces*/ replace(/<[^>]*>/g,''). /*strip existing html tags */ split(''), output = ''; for (var w = 0, l = letters.length; w < l; w++) { output += '<span style="color:' + ((w % 2) ? colorpair[0] : colorpair[1]) + ';">' + letters[w] + '</span>'; } el.innerHTML = output; }
http://stackoverflow.com/questions/1...ing-javascript
This is very cool too: http://rainbowcoding.com/how-to-crea...ss-javascript/
Want to hide these adverts? Register an account for free!