The style attribute specifies an inline style for an element. To set the font color in HTML use the style attribute.
Coloring your website is a part of CSS inline styling.
Script text color html. The attribute is used with the HTML. This is known as inline CSS. Function changeColor documentbodystylecolor purple.
You can change the color and size of your text right inside its tag with the color and font-size properties. DocumentgetElementById changeonclick changeColor. You do it with the style attribute in HTML.
This means you need to use the style attribute in the opening tag you wish to add HTML color to. In HTML colors can also be specified using RGB values HEX values HSL values RGBA values and HSLA values. Rgb 255 99 71 ff6347.
Youd either have to put this script at the bottom of your page right before the closing body tag or put the handler assignment in a function. In the HTML code below we will change the color and size of the freeCodeCamp text. You may use the color property to change the color of your text or background-color to change the color of the background.
Set the text-color for different elements. You can use the color name to change the text color. There is no special HTML color tag as design is not the main function of HTML.
How to Change Text Size and Text Color in the HTML Tag. Show activity on this post.