oRookie oRookie - 3 months ago 7
HTML Question

How can I change the font color of all texts of your website using Javascript?

I learned, that there are ways to change the color of single texts. However I'd like to find out how to change the color of all texts of my website at one time.

I found the

document.body.style.backgroundColor = "black";
function and hoped that there would be something similar for fonts.

Edit: I am sorry. I guess I was misleading some people. I know what CSS is ofcourse... I wanted to find a way to change the colors while using the website. So I'd like to find a way to change the CSS properties via JavaScript.

Answer

Use the CSS color property:

CSS

* {
   color:  [color-value];
}

This will change the font color of all elements using the universal (*) selector. If necessary, you may need to use the !important declaration (not recommended, but useful: see link) to override other styles.

JavaScript

document.body.style.color = [color-value];
Comments