Control your color gradient tool!
Posted By Predrag on June 12, 2006
There is one thing you should know about gradients no matter what application you use – it is a tricky business. You can create nice color harmony or ruin your layout in 3 mouse clicks.
Back in 2002 I was avoiding it wherever possible from various reasons:
- Page load was longer
- It looked unprofessional and lame
- 2 of 3 gradients throughout the Web were followed with some horror looking headline, 3D rotating logo and/or heavy JPEG compression
Of course, those days CSS was used for changing colors in anchor tags - rarely for something more. Now it’s different – we use style like background-image, background-repeat, background-position and whoohoo – with a 0.1KB GIF image of 50×1 pixels in gradient, we have a cool looking header background. If we use some cool font, sometimes it’s more than enough for good start in our design.
So, now we know what we need and I am more than sure you know how to create gradient in your favorite application. You pick two colors, you draw a direction line and that’s it! Gradient is here. We just need to learn how to control it.
Here are some ideas how to refresh your current web sites…
Use close-by colors
Don’t pick red and green colors to create your gradient. Use shades of same color! More importantly – use close-by shades! Here is what I’m talking about:

I don’t want to waste my words nor my eyes on this one. You’ve seen a lot of these around the web. Perhaps with all the colors of the rainbow…
Let’s try this one:

OK, you must admit this one looks better than the top one. It’s clean and simple. If you can’t manage the shades, please use simple fill without gradient.
Now, the magic. I used 2 close colors (in this example I used #b91716 and #990709). Below is the version with 2 far-away colors.


Argh. This looks ugly and far from acceptable.
So, that is what I am babbling about for all this time – use close by shades of the same color for best effect. This way, you can cut 1px wide image and through CSS you can place it in your website header without any hassle.
If we go back to winner, gradient #3, we can further polish it. We can add some pattern over it, border around it and that is basically it. (This is not necessary at all; I just thought I could make you think and experiment further). This is what I created in less than a minute:

Conclusion: use near by shades of one color for best achievements.
Use top-to-bottom gradient direction
If you are Photoshop user, you have access to a lot of possible variations of a gradient. If you use GIMP, you have a bit less, but that is not an issue. If you are working for print, spend all day creating your gradient – only limit you have is your printer, Pantone colors match in your printing company and your imagination.
However, if you are creating for the Web, than you need to sing another song. Use top-to-bottom gradient direction! Why? It’s easier to code it. Effect you’ll achieve with some other directions won’t look much better, but the pain in your head will grow when the coding type comes.
That’s more than enough to give you a head-start. Web 2.0 environment and XHTML Strict DTD are forcing us (bless them, BTW) to separate code and design – minor gradients and simple-as-possible code is what we need for the upcoming time.
Comments
Cassis says:
Predrag says:
Jackie says:
3 Responses to “Control your color gradient tool!”
January 6th, 2007 at 2:16 pm
“with a 0.1KB GIF image of 50×1 pixels in gradient”
If the browser has a viewport width of 1600px and that image is actually repeated horizontally wide, your 0.1KB GIF file is repeated 1600 times. That makes 160KB of memory without even allocating memory for each image position into the page. Some old computers (or even browsers) may eat 100% of your CPU during your visit of the page.
You better make a 50×64 image. Your GIF (or PNG) file won’t be that much bigger in size because the compression algorythm takes care of the horizontal repetition. That way the image is only repeated 64 times. Let say your new image size is 0.12KB : with the same calculation you only have 7.68KB memory used ! I over simplify the calculation but I hope you see the point.
The best examples of misusing the background-image is multiple 1×1px background image in large screen size. A nightmare for the renderer.
Nice website and interesting articles (I like the red rabbit pretty much, I will try it soon)
Cheers !
Cassis
PS: tab focused buttons under firefox have light yellow background and white text in your CSS
March 23rd, 2007 at 4:00 pm
Hi Cassis,
I must say I disagree with you on this one. Main thing is you look from the diferent perspective. Small image, no matter how many times repeated on the page, still takes very small portion of page download time. How that will be rendered, and how much of memory will it take, depends of the platform.
Optimising that is not part of my work.
I understand what you are saying, but I never experienced my CPU 100% being eaten because of the 1px gradient. Additionaly, I never read something similar about this problem before, and I follow a lot of design blogs on the Web.
Best wishes,
P.
PS Re: PS, I use firefox, but can’t see the problem. What do you mean exactly?
June 2nd, 2008 at 12:28 am
Many thanks for your tute. My CSS/html book says that some browsers can choke on reproducing 1px wide images ..it says to make them wider.
thanks. Jackie