Using CSS (Cascading Style Sheets) it's very easy to add drop shadows to the images on your webpages. In this article, I provided you with four examples of how to use CSS to add drop shadows to your pictures. Go ahead and experiment with different drop shadow colors and offsets.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site

Add Drop Shadows to Your Pictures

NASA Astronaut Jim McDivitt

Using CSS (Cascading Style Sheets) it's very easy to add drop shadows to the images on your webpages. The code for the image with drop shadow above is shown below.

<span style="background-color:lightgrey; width:230; height:230;">
<img style="position:relative; left:-4px; top:-4px;" width=230 height=230 src="mcdivitt.jpg">
</span>

The image is placed inside a <span> element. The style rules for the span set the width and height of the span to the same width and height as the image. The background-color rule sets the background color of the span, which becomes the drop shadow. Note that I set the background color to light grey.

Style rules for the image within the span set its position to relative and set it's left and top proerties to -4px, shifting the image 4 pixels to the upper-left of the span. This creates the offset that exposes the background color of the span.

-  You can experiment with different offset values and background colors. If you want to fine-tune your drop shadow colors, instead of using color names, use hexadecimal color notation. To keep it simple, we'll use the color name in these examples.

In the example shown below, instead of defining a background color for the span, I gave the span a background image.

NASA Astronaut Jim McDivitt

<span style="background: url(shadow.jpg); width:244; height:244;">
<img style="position:relative; left:-4px; top:-4px; border-style:solid; border-width:1px;" width=230 height=230 src="mcdivitt.jpg">
</span>

Web Design Sections

RSS Feed RSS Feed

Cascading Style Sheets
Understanding CSS Selectors
The CSS Box Model
Understanding CSS Positioning
Add Style to Your Blockquotes
How to Overlay Text on an Image
Display Overlapping Images on Your Webpage
Style Your Imagemap Tooltips
How to Style a List
How to Style a Table
How to Change the Mouse Pointer
How to Use a Starburst on Your Web Page
How to Use a Pull Quote
Easy Scrollable Area Code
Easy CSS Buttons
Create CSS Button Rollovers
Create Custom Horizontal Rules
Easy CSS Popup Windows
Add Drop Shadows to Your Pictures
Easy Text Drop Shadows
Spice Up Your Web Forms with Color and Graphics
Setting a Larger First Letter
Make a Fixed-width Variable-height Round Cornered Box
Easy Visual Effects to Spice Up Your Webpage
HTML, XHTML, and CSS Bible
Web Designer's Reference
Pro CSS Techniques
Code for Horizontal Drop-down Menu Bar
Easy Rollover Menu Code
Easy CSS Tabbed Navigation
Easier Expanding Menu Code
Easy Three-level Expanding Menu Code
Easy Floating Menu Code


[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2009 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269