CSS properties - color

revision:


color property

- specifies the color of text.

Tip: use a background color combined with a text color that makes the text easy to read.

CSS syntax : color: color | initial | inherit;

Property values:

color : specifies the text color

initial : sets this property to its default value.

inherit : inherits this property from its parent element.

JavaScript syntax: object.style.color="#0000FF"

example: color property

This is heading 1

This is an ordinary paragraph. Notice that this text is red. The default text-color for a page is defined in the body/div selector.

This is a paragraph with class="ex". This text is blue.

The color of the text can be specified with an HSLA value.

code:
                    <div class="Div-A">
                        <h4>This is heading 1</h4>
                        <p>This is an ordinary paragraph. Notice that this text is red. The default text-color for a page 
                        is defined in the body/div selector.</p>
                        <p class="ex">This is a paragraph with class="ex". This text is blue.</p>
                        <p class="ex2">The color of the text can be specified with an HSLA value.</p>
            
                    </div>
                    <style>
                        .Div-A{color: red;}
                        h4 {color: #00ff00;}
                        p.ex {color: rgb(0,0,255);}
                        p.ex2{ color: hsla(89, 43%, 51%, 0.6);}
                    </style>