March 31, 2010

Say Hello to RGBA Color with CSS3

If you’re a web designer or front-end developer stop using Hexadecimal colors. RGBA offers your greater flexibility and control to make your designs pop and get you out of PhotoShop.

Let’s use a bright blue for example. I can define this as #1c0abc in Hexadecimal or as an rgb(28,10,188) RGB value in my CSS.

style=”background-color:#1c0abc;”

Bright Blue

or

style=”background-color: rgb(28,10,188);”

Bright Blue RGB

with RGBA, you can add a fourth value, the “alpha” transparency of the color. 0.0 is 100% transparent. 1 is fully visible.

Alpha Transparency

Above is five stops, with the A value .2-1.0 in .2 increments. rgba(28,10,188, 0.2), rgba(28,10,188, 0.4), rgba(28,10,188, 0.6), rgba(28,10,188, 0.8), rgba(28,10,188, 1.0).

RGBA is better than the CSS opacity element, because individual colors can be transparent without effecting the opacity of the entire element. You can isolate the transparency of the border, background color and text color without effecting the transparency of the other elements.

RGBA is part of the CSS3 standard. Current support in all major browsers but Internet Explorer. A good technique for a IE fallback is to stack color properties, ending in RBGA. Newer browsers will use the last color and IE will ignore the CSS properties it can’t understand.

This technique requires a slight shift in your color coding, but you gain additional flexibility in your designs.

Paul Weinert
Author

Paul Weinert is our founder, managing principal and spirit animal. He’s one of those odd people you meet that was born in Portland, grew up here and still lives here for some reason. If you had two words to describe Paul after meeting him, we’d bet you’d use “charmingly quirky”.

Paul started GRAYBOX in February 2009, and for the first four years, GRAYBOX had a blend of a contract staffing firm and a traditional agency. GRAYBOX then hired our first employees in 2012 and has been growing ever since. Professionally, Paul has a background in internet business consulting, working especially with mid-market ecommerce, healthcare, and tech companies. He worked as a user experience designer, web developer and internet marketer. Nowadays, Paul serves as our company visionary, team mentor and head of executive leadership — Paul is extremely proud of the entire team and the company. He’s constantly humbled by the team’s awesomeness and the caring community that’s sprung up from his initial ideas.

Beyond GRAYBOX, Paul is married, has two young boys and lives in NE Portland. He’s also an active foster parent, mentors other local entrepreneurs, and volunteers on local non-profit boards. Businesswise, aside from GRAYBOX, Paul has started a few other businesses and is an active investor in the local startup scene.

For the sheer joy of it, let’s play 2 truths and a lie:

  1. Paul firmly believes that any activity would be better if on a boat.
  2. Other than this whole Internet thing, Paul has basically no other skills or expertise in anything.
  3. Paul is rare unicorn, actually born and raised in Portland.