On this page
A pale sky can blend into a light card. A deep shadow can do the same on a dark surface. An inset outline draws a fine line over the outermost pixels. Compare the top edges of the same painting below.
This example builds on Jakub Krehel’s image-outline technique.
Why not a border
A border participates in the box model. Depending on box-sizing, it can enlarge the box or take space from the image inside it. An inset line leaves the layout dimensions alone. The example paints a 1px inset shadow on an overlay so the line stays visible over the image and follows its rounded corners.
How strong
Start at 10%. Try 0% to see the unframed image and raise the opacity until you can just trace its edge. Switch between light and dark surfaces to see how the same strength reads on each.
Try another image before committing to a value. A line that reads clearly against a pale sky may disappear over a mid-tone photograph.
Avatars
At avatar size, a photo and an initial can have very different edges. Apply the same inset line to the photo, graphic, and initials to give the set a consistent shape. Use a circular radius on the frame.
Usage
Copy the CSS from How strong and wrap your image as shown below. The snippet uses a black edge on light surfaces and a white edge inside data-theme="dark".
<span class="image-frame">
<img src="/cover.jpg" alt="Fishing boats on the beach" />
</span>
Keep a separate, clearly visible focus indicator when the image is inside a link or button.



