Learn how to add transparency
Takeaway: Transparency lets an image be displayed on a Web page with the page's background showing through the transparent parts of the image. Here's how to add transparency to your Web site.
By Paul Anderson
Most image editors offer the option of transparency, also referred to as a mask or alpha channel. Transparency lets an image be displayed on a Web page with the page's background showing through the transparent parts of the image.
The current Portable Network Graphics (PNG) format includes a full 8-bit alpha channel, with 256 gradations of transparency, to sit alongside the RGB channels. The current Web formats can't match that, but GIF does have the equivalent of a 1-bit alpha channel: You can specify a single color on the palette that should be rendered completely transparent.
To give a GIF transparency, don't bother with the direct transparency or masking offered within most image editors. They seldom take transparency into account when exporting a GIF, and it's of little use given a GIF's all-or-nothing capability. Instead, make sure the areas that you want transparent are all of a single color and that you don't need that color to be visible anywhere in the image. You may have to change the portions you want transparent to a new color , taking care to stay within the total 256-color limit.
Your image editor should offer the option of picking a color to declare transparent in the Save As or Export options, on an Optimization panel, or in a control or menu marked Palette or Color Table. Select the color that you want, and you should get a GIF with the appropriate areas transparent.
Pick a background color
If the visible part of your GIF has antialiased edges, make sure that its background is the same basic color as the background of the Web page where it will appear. The original background is interpolated into the antialiased region, so if the backgrounds don't match, you end up with a thin visible border of the original background color around your image.
Some very old browsers and non-Web applications don't support GIF transparency, and these applications will display the selected color. If you're a stickler for backwards-compatibility, or expect the same GIF file to be used in other applications, make sure that the transparent color looks acceptable when visible.
Paul Anderson is associate technical editor for CNET Builder.com. His responsibilities don't include handling graphics, so naturally, he handles them all the time.




Original
Transparent
Transparent, purple background
Transparent, orange background
White Papers, Webcasts, and Downloads
- Advanced Java Memory Analysis with JProbe Quest Software Memory issues in Java applications can cripple performance and cost your ... Download Now
- Five Steps to Determine When to Virtualize YourServers VMware Thinking of virtualizing the servers at your company? Use this step-by-step guide to determine when's the best time to make your big move. Download Now
- Building the Virtualized Enterprise with VMware Iinfrastructure VMware VMware virtualization software has been adopted by over 120,000 enterprise ... Download Now
- The Impact of Virtualization Software on Operating Environments VMware Today's use of virtualization technology allows IT professionals to ... Download Now
- Dell Helps Medical University of South Carolina Bring the Intelligent Classroom to Life Dell Established in 1824, Medical University of South Carolina (MUSC) is one of ... Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET


