Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Defining Colors Using Css


2 replies to this topic

#1 delivi

    Trap Grand Marshal Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPip
  • 1,320 posts

Posted 01 June 2007 - 02:39 PM

We can specify the colors using different techniques in CSS to use within documents. No color should ever be specified within an XHTML document, it should be specified through CSS.

Lets see the different ways of specifying colors.

I. Using Color Names

You can use color names for specifying a standard set of colors. Only 16 named colors are valid for CSS. They are,
White (#ffffff), Black (#000000), Red (#ff0000), Green (#008000),
Blue (#0000ff), Silver (#c0c0c0), Gray (#808080), Teal (#008080),
Lime (#00ff00), Olive (#808000), Yellow (#ffff00), Maroon (#800000),
Purple (#800080), Fuchsia (#ff00ff), Navy (#000080), Aqua (#00ffff)

II. Using RGB Hex Codes

RGB Hex codes are most commonly used to specify colors in CSS. RGB Hex codes are six digit hexadecimal numbers. A hexadecimal numbers is made up of the digit 0-9 and letters A-F, where A representing 10 as a single digit, through to F representing 15).

Each RGB Hex Color code contains of three parts. Each part when converted to decimal will be equal to a value between 0 and 255 (00 to FF).

An example RGB Hex Color code is "#FFF8DC". The first pair of digits refers to the amount of red in a color ("ff"), the second specifies the amount of green ("f8"), and the last pair the amount of blue ("dc").

The RGB Hex Color code is always prefixed with a # symbol.

III. Using Short RGB Codes

When each of the three pairs of a RGB Hex color code consist of two of the same digit, for example #ffdd77, the code can be shortened or abbrevated as #fd7.

Remember this can only be done only when all three of the pairs are made up of two identical digits.

IV. Using Decimal Values

CSS allows you to specify the color values in decimal form. This will be quite useful if you have trouble working with hexadecimal values. You can just get the decimal values for the colors you use from your image editor or a color picker.

The following syntax is used for decimal color definitions in CSS:
* {
	1. color: rgb(255, 248, 220); 
 }

The above code translates to the color #fff8dc. The value for each of the three colors red, green and blue - is defined as a number between 0 and 255.

IV. Using Percentages in RGB

The Colors can also be specified in CSS as percentages in RGB. You need to add the percent sign (%) after the number you wish to use as percentage for each color.

The following syntax is used for defining colors using percentages in RGB:
*{
	  color: rgb(100%, 60%, 200%);
 }

The value for percentage ranges from 0 to 100 for each color component.

Note:
* If the value used for specifying colors exceeds the limit i.e. greater than 255 then the maximum value is used.
* No negative values will be accepted.
* Only the Hex Values for colors is supported by all other web programming languages.

#2 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 02 June 2007 - 12:03 AM

And here is a page with lots of colour choices to assist with Hex colour-codes:

http://jlhaslip.trap...olour_grid.html

#3 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 18 January 2010 - 05:37 PM

hello there do you know how I can change the colurs of my letters on call of duty modern warefare 2  thx

-reply by darcness




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users