CSS Properties: How to specify the text color?
Solution:
HTML Code:
Explanation:
- This HTML document demonstrates how to specify text color for different elements using CSS.
- The CSS style block defines rules for the div and h1 elements.
- The text color for all div elements is set to a shade of blue (#3333FF) using the color property.
- The text color for all h1 elements is set to red (#FF0000) using the color property.
- The HTML body contains an h1 element with the text "w3resource Tutorial" and a div element with text describing CSS.
- The text color of the h1 element will appear as red, while the text color of the div element will appear as blue, as defined by the CSS rules.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics