spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / css_color / 1 current pageTo page 2To page 3
[next]

A (CSS) Horse of a Different Color - Part 1

.NET Developer
Steinman Recruiting Associates
US-PA-York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Metasploit 3.2 Offers More 'Evil Deeds'
'Thank You Apple. Seriously.'
The Buzz: BlackBerry App Store Seen Next

Currently, the World Wide Web Consortium (W3C) is working on enhancements and improvements to CSS with the forthcoming CSS3 specification. Unlike the previous specs, the W3C is working on creating a new spec in a piecemeal fashion, focusing on individual “modules” dealing with a specific issue, like fonts, backgrounds, borders and so on. The idea is to not only make the process of change more public and visible (by posting changes and updates to their Web site), but also to give browser developers a chance to work on future developments prior to them being made official.

One of the CSS3 modules deals with color, and if it is fully adopted, it promises to introduce a number of changes in the ways you can set colors on a Web page.

HSL Color Values

A wholly new way of setting color that has been proposed is to use HSL color values. HSL is short for “Hue, Saturation and Lightness”, and it is arguably a more intuitive way of specifying color values than using either hexadecimal code or RGB decimal values. HSL describes color values in terms of its placement on a color circle, how “deep” a color is, and how light or dark it is. The first value of HSL is described by a color circle with values ranging from 0 to 360. Red colors lie about 0 degrees, greens at around 120 degrees and blues around 240 degrees. Both saturation and lightness are represented by percentage values: 100% saturation is the “full” value for a given color, whereas 0% represents the grayest value for that color. Then there is the “light” value: 100% lightness is bright, sometimes near-white, 50% is “normal” and 0% lightness is very dark, sometimes near-black depending on the color. The following code snippet shows how “full” red, green and blue values would be represented using HSL:

{color: hsl(0deg, 100%, 50%)} /* red - equivalent to #FF0000 */
{color: hsl(120deg, 100%, 50%)} /* green - equivalent to #00FF00 */
{color: hsl(240deg, 100%, 50%)} /* blue - equivalent to #0000FF */

Once you know where a color value lies on the color wheel, it is a relatively easy thing to tweak the value; making a color more green or blue, for example, de-saturating it, or making it darker or brighter as needed. So, for example, if you wanted to make a particular green lighter or darker, you just have to play with the final value until you get what you want, as you can see in the following code snippet:

{color: hsl(120deg, 100%, 50%)} /* ‘normal’ green */
{color: hsl(120deg, 100%, 25%)} /* a lighter green */
{color: hsl(120deg, 100%, 75%)} /* a darker green */
{color: hsl(120deg, 100%, 100%)} /* lime */

If you change the middle, saturation values, you get lighter or darker pastel-like colors, as you can see from the following code snippet:

{color: hsl(240deg, 3% ,100%)} /* ghost white */
{color: hsl(240deg, 8%, 98%)} /* lavender */
{color: hsl(240deg,78% ,44%)} /* midnight blue */

The prime advantage HSL has over hexadecimal and decimal RGB values is that they more intuitively show how close one color is related to another. For example, the hexadecimal color value for the color name “PowderBlue” is #B0E0E6. The only slightly lighter “LightBlue” color is #ADD8E6. Doing this type of conversion in your head using hexadecimal is almost impossible. Decimal values are slightly better at showing the small difference between these two colors, which are 176,224,230 and 173,216,230 respectively. But you are still trying to mix different values of red and green in order to tweak the type of blue you want. But the HSL values for them – 187deg, 23%, 90% and 195deg, 25%, 90% respectively – best show just how slight the difference is between them, and also provides a better hint as to how to make a given color more or less blue, and how to change its brightness. You are no longer dealing with red and green values, just playing around with different shades of blue, which makes things much easier.

A final word about this: keep in mind that the use of HSL in CSS color properties has not as yet been finalized. Things may end up being different in the final specification, so just consider this a “head’s up” as how you may be able to set HSL color values in the near future.


home / programming / css_color / 1 current pageTo page 2To page 3
[next]



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Tripwire Whitepaper: Seven Practical Steps to Mitigate Virtualization Security Risks
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview · Controllers: Programming Application Logic - Part 2 · How to Use JavaScript to Validate Form Data
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Choosing the Right Online Backup Provider · Mother Avaya Nurtures Her Technology Partners · Software as a Service a Winning Model for Hotspot Provider

Created: March 27, 2003
Revised: June 17, 2003

URL: http://webreference.com/programming/css_color/1