
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Setting Color Property in CSS
We can define colors for text, borders and background of elements using CSS. The color property is used to specify the text color for an element.
Syntax
The syntax for CSS color property is as follows −
Selector { color: /*value*/ }
The following examples illustrate CSS color property −
Example
<!DOCTYPE html> <html> <head> <style> div { color: seashell; background-color: lightcoral; } p { font-size: 1.5em; color: blue; background-color: palegreen; box-shadow: 0 0 5px 1px rgb(0,0,0); } </style> </head> <body> <div> This is demo text. <p> Text added for reference. </p> This is demo text 2. </div> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html> <head> <style> * { text-align: center; } h3 { color: red; border: 2px ridge rosybrown; } p { color: royalblue; background-color: cornsilk; box-shadow: 0 0 5px 1px deeppink; } </style> </head> <body> <h3>Demo Demo Demo Demo</h3> <p>Demo text here</p> </body> </html>
Output
This gives the following output −
- Related Articles
- Setting up Background Color in CSS
- Setting Text Color using CSS
- Setting up Background Color using CSS
- Setting Text Color Working with CSS
- Setting the Color of Links using CSS
- Setting the Location Color Stops using CSS
- CSS outline-color property
- CSS caret-color Property
- Setting the element's text color using CSS
- Usage of color property in CSS
- The outline-color Property in CSS
- The border-color Property in CSS
- Usage of background-color property in CSS
- Usage of border-color property in CSS
- Setting Tab Sizes in HTML with CSS tab-size Property

Advertisements