Color text | SoloLearn: Learn to code for FREE!


Color text

Hello, I'm new at learning Web (Js) and I would need to know how can I change the text's colour? Like from black to orange.

11/23/2017 12:29:13 PM

Mihnea-Stefan Bondor

2 Answers

New Answer


Before to learn change color, you should learn how to set HTML tad and id. Once you have your text with HTML tag and id, you can use document.getElementById to access that DOM element. From the return of the DOM variable, you can access the color selector using style method. For example: to set a text with class name of txt in HTML <p class="txt">Text</p> to access that DOM element, in JavaScript: var txt = document.getElementById('txt'); finally use style method to change the css color: = 'orange';


Thank you Calvin.