- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Setting Text Color Working with CSS
The CSS color property is used to set text color for an element.
Syntax
The syntax of CSS color property is as follows −
Selector { color: /*value*/ }
Example
The following examples illustrate CSS color property −
<!DOCTYPE html> <html lang="en"> <head> <style> div { height: 100px; width: 200px; margin: 10px; display: flex; float: left; font-size: 1.4em; word-spacing: 30px; line-height: 4.5em; border: thin solid blue; border-radius: 40%; text-align: center; color: rebeccapurple; } div + div{ background-color: beige; color: red; text-align: justify; text-decoration: line-through; } </style> </head> <body> <div>One Two</div> <div>Three </div> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html lang="en"> <head> <style> p { margin: 10px; display: flex; float: left; border: 3px groove green; text-align: center; color: rebeccapurple; } span{ background-color: beige; color: red; text-decoration: underline; } </style> </head> <body> <h2>What is Tableau?</h2> <p>Tableau is a Business Intelligence tool for visually analyzing the data. <span>Users can create and distribute an interactive and shareable dashboard, which depict the trends, variations, and density of the data in the form of graphs and charts. </span> Tableau can connect to files, relational and Big Data sources to acquire and process data.</p> </body> </html>
Output
This gives the following output −
- Related Articles
- Setting Text Color using CSS
- Setting the element's text color using CSS
- Text Indentation Working with CSS
- Text Transformation Working with CSS
- Setting Color Property in CSS
- Set Text Alignment Working with CSS
- Emphasis text and color with CSS
- Setting up Background Color using CSS
- Setting up Background Color in CSS
- Setting Text Alignment using CSS
- Setting the Color of Links using CSS
- Setting the Location Color Stops using CSS
- How to set the color of a text with CSS
- How to override the default text selection color with CSS?
- Animate CSS text-decoration-color property

Advertisements