Checkout this video:
The first two digits (ff) represent the amount of red, the next two (ff) represent the amount of green, and the last two (ff) represent the amount of blue. The highest value possible for each color is ff, which translates to 255 in decimal notation. This means that the strongest red is ff0000, the strongest green is 00ff00, and the strongest blue is 0000ff.
Here’s an example of how to change the color of a heading element:
// get the element you want to change
var heading = document.querySelector(‘h1’);
// change its color property to any valid CSS color value
heading.style.color = ‘red’;
Changing Background Colors
One way to change the background color is to use inline CSS, like this:
This text will be red.
Changing Text Colors
To change the color of text in HTML, use the color attribute. The color attribute can take one of two different forms:
-The color name: This is some red text.
-The hexadecimal value: This is some red text.
Changing Link Colors
Changing Border Colors
One way to change the color of an element is to set its border color style. For example,
document.getElementById(“myDiv”).style.borderColor = “red”;
This will change the border color of the element with an ID of “myDiv” to red.
Changing Button Colors
Changing Input Colors
document.getElementById(“myDiv”).style.color = “red”;
Changing Heading Colors
To link to a separate CSS file, you'll need to use the tag. Here's an example: