w3reference home
CSS Tutorial


Bookmark and Share

CSS Colors

There are many commands in CSS to set the colors of the text, backgroud etc. to make the web page look like you want it to. The value can be set either as a rgb value, hexadecimal number or a color name.

Set Text Color

The color property can set the color of your text. The value of color property can be set either as a rgb value, hexadecimal number or a color name. Example:
<html>
<head>
<style type="text/css">
h3.rgb {color: rgb(255,255,0)}
div.hex {color: #dda0dd}
p.name {color: red}
</style>
</head>

<body>
<h3 class="rgb">The color is specified as an rgb value</h3>
<div class="hex">The color is specified as a hexadecimal value</div>
<p class="name">The color name is specified</p>
</body>
</html>
Output:

The color is specified as an rgb value

The color is specified as a hexadecimal value

The color name is specified


Highlight Text

To highlight a text, i.e. to set the background color of a text, background-color property is used.
Example:
<html>
<head>
<style type="text/css">
div.rgb {background-color: rgb(255,255,0)}
span.hex {background-color: #dda0dd}
p.name {background-color: green}
</style>
</head>

<body>
<div class="rgb">The highlighted color of this text is mentioned in grb
</div>
<span class="hex">The highlighted color of this text is mentioned in hex
</span>
<p class="name">The color of this highlighted text is mentioned</p>
</body>
</html>
Output:
The highlighted color of this text is mentioned in grb
The highlighted color of this text is mentioned in hex

The color of this highlighted text is mentioned


Set Background Color

You can set the background color of any element by using the property, background-color. If you need to set the background color of the web page, use background-color property in the element.
Example:
<html>
<head>
<style type="text/css">
body {background-color: yellow}
p.green {background-color: #00ff00}
div.trans {background-color: transparent}
</style>
</head>

<body>
The background color is set to yellow.
<p class="green">This paragraph is green</p>
<div class="trans">This division is transparent</div>
</body>
</html>
The example above must be quite clear. One thing new must be the color, transparent. This is the default background color.
Output:
The background color is set to yellow.

This paragraph is green

This division is transparent
Code Validator
Learn FTP
Color finder
Link Checker
Free web designs
Coming soon!
Interview Questions...
'w3reference : Learn by examples ... Advanced to beginner's tutorials ...'
Ajax: AJAX tutorial1 | Apache: Apache HTTP Server | Restarting Apache | CSS: CSS Border | CSS Syntax | CSS Selector | CSS Comment | CVS: CVS Release | CVS Login | CVS Logout | CVS Annotate | Databases: Rolap Tutorial | OLAP Tutorial | OLTP Tutorial | data warehousing | Expect: HTML: html | Linux: Dot (.) conf files | Linux Mount Point | Linux Filesystem | SSH Tutorial | Linux Commands: cal | cat | cfdisk | chroot | MySQL: MySQL Commands | PHP: PHP Basics | PHP Variables | PHP Output (echo/print) | PHP String Concat | PL/SQL: PL/SQL Data Types | PL/SQL Control Structures | PL/SQL File Extensions | PL/SQL DBMS_OUTPUT package | Python: My first Python program | Shell: Starting Bash | Bash Redirection | Bash Pipes | Bash Variables | SQL: SQL Transactions | SQL Constraints | SQL Drop | SQL Union & Union All | SVN: svn architecture | SVN Repository | SVN Import | SVN Checkout | Tech: soap | Web Designing: Web Hosting | HTML/XHTML/CSS code validator | Learn FTP | Search Engine Optimization Tips | www: XML: XML vs HTML | XML Syntax | XML Tags, Elements and Attributes | XML Namespaces |
Sitemap | Disclaim | Privacy Policy | Contact | ©2007-2009 w3reference.com All Rights Reserved.