Code2Design.com

User login

Programming

The Layout

Navigation

Popular content

Resources

Who's online

There are currently 0 users and 10 guests online.

Rgb-colors in css-files

For some reason or another, hexcolors are almost always used in css-files. Personally, I prefer to use rgb-colors. It is valid code according to w3schools.com.

Some examples of hexcolors: 000000 = black, ff0000 = red, 00ff00 = green, 0000ff = blue, ffff00 = yellow, ff00ff = magenta, 00ffff = cyan and ffffff = white (in other words, the values are written with the hexadecimal numerical system, which uses the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e and f).

Some examples of rgb-colors: 0,0,0 = black, 255,0,0 = red, 0,255,0 = green, 0,0,255 = blue, 255,255,0 = yellow, 255,0,255 = magenta, 0,255,255 = cyan and 255,255,255 = white.

There are perhaps advantages with using hexcolors in css-documents that I'm not aware of, but according to my experience the result doesn't differ much (if at all) if you use rgb-colors instead.

Write like this to get blue text:
Css: .blue {color:rgb(0,0,255);}
Html: <p class="blue">The text returns blue.</p>
Write like this to get blue text and grey background:
Css: .blue_and_grey {color:(0,0,255); background:rgb(224,224,224);}
Html: <p class="blue_and_grey">The text returns blue. The background returns grey.</p>


Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <br /> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use BBCode tags in the text, URLs will be automatically converted to links
More information about formatting options



Like what you see?

Why not add more? C2D is looking for other Christian Web Masters who would like to help write articles for this site. If you have expericance in FLASH, CSS/HTML, PHP/MySQL, PhotoShop/GIMP, Blender, Javascript, or just General Design - our users would love to hear what you have to say. Contact Us

delicious   digg   reddit   magnoliacom   newsvine   furl   google   yahoo   technorati