Creating reflections in our images with webkit-box-reflect

- Andrés Cruz

ES En español

Creating reflections in our images with webkit-box-reflect

We will see how to apply the webkit-box-reflect property to create reflections; additionally, its syntax offers a significant number of values which we can set to our liking to change aspects ranging from position and offset to the possibility of applying masks through CSS gradients to create reflections.

Creating reflections in CSS has always been an eye-catching effect, but it normally involves duplicating elements, applying transformations, playing with opacities, and adjusting gradients manually. In this context, -webkit-box-reflect appears as a curious property that greatly simplifies the process… although with important nuances.

In this guide, I explain what box-reflect is in CSS, how -webkit-box-reflect actually works, what values it supports, how to create reflections with gradients, and, above all, when it makes sense to use it and when it doesn't—something that isn't always clarified in the official documentation.

We previously saw how to use borders in CSS.

What is -webkit-box-reflect and what is it for in CSS

The -webkit-box-reflect property allows you to create a visual reflection of an element in a specific direction: above, below, left, or right. It acts as if the browser duplicates the element's content and reflects it like a mirror.

Unlike other CSS effects, here we are not manually transforming the element, but applying a property that generates the reflection automatically, which saves a lot of work when you are only looking for a quick visual effect.

In my case, I have used it mainly with images and decorative elements, where the reflection provides visual impact without the need for a complex structure.

Browser support and why it is not a standard property

As you can tell by the name of the property in question established in this entry (webkit-box-reflect), support is only for webkit browsers, which means it will only work in browsers that use the webkit platform such as: Chrome, Opera, and Safari. 

The latter tells us that it is not a property supported by a large number of browsers at all and therefore it is not highly recommended to use it for final applications, but rather for educational purposes or to experiment a bit.

Before using box-reflect in CSS, one key point must be clear: it is not a standard property.

Browsers compatible with webkit-box-reflect

It works only on WebKit or Blink-based browsers, such as:

  • Chrome
  • Safari
  • Opera
  • Edge (Chromium-based versions)

It does not work in Firefox or browsers that do not support the -webkit- prefix.

When it makes sense to use box-reflect and when it doesn't

From experience, it is not recommended to use -webkit-box-reflect in final applications or critical interfaces, as support is not universal and may change or disappear.

Where it does make sense:

  • Visual experiments
  • Demos
  • Educational projects
  • Highly controlled landing pages
  • Proofs of concept

When I tried it in real layouts, I realized that if you don't align the element and its reflection well, the document flow can easily break, something that is not usually mentioned in quick guides.

The syntax of the webkit-box-reflect property in detail

The syntax is simple but very flexible:

-webkit-box-reflect: <direction> <offset> <mask>;

Each part is optional (except for the direction), and they can be combined depending on the effect you are looking for.

As we will see below, we can place the reflection on any of the sides we want, including below, as we are interested in for our example:

Therefore, we use the following CSS rule:

-webkit-box-reflect: below;

Direction values: above, below, left, and right

These values indicate where the reflection appears:

-webkit-box-reflect: below;-webkit-box-reflect: above;-webkit-box-reflect: left;-webkit-box-reflect: right;

In practice, the bottom reflection (below) is usually the most used, especially with images, because it better mimics a realistic reflection.

Although to position ourselves in the different positions or directions, we have different values that we can set:

-webkit-box-reflect: left for reflection on the left

-webkit-box-reflect: right for reflection on the right

-webkit-box-reflect: above for reflection on the top

Setting offsets with the webkit-box-reflect property

If we want to place a separation between the image and the reflection, we use the second value; for example, to separate it by about 80px for each of the examples we saw earlier:

You can use any valid CSS unit: px, em, rem, etc.

-webkit-box-reflect: above 8px
-webkit-box-reflect: right 8px
-webkit-box-reflect: left 8px
-webkit-box-reflect: below 8px

Applying masks in the webkit-box-reflect property to obtain reflections:

As indicated at the beginning, masks or filters can be applied to obtain interesting effects; in our case, we are interested in obtaining a kind of blurred reflection of the image:

-webkit-box-reflect: below 8px linear-gradient(transparent, white);

Which obviously can be applied to the different positions we saw earlier; in general, the webkit-box-reflect property is quite useful as it prevents us from doing all this work by hand; the only problem (apart from the fact that it only works in webkit browsers) is that you have to align both the image and the reflection so that it doesn't break the basic flow of our document as you will see if you study the CSS of the previous examples a bit.

Using images and gradients as a mask

This is where -webkit-box-reflect becomes really interesting. You can apply a mask, usually with linear-gradient, to create a fade effect:

-webkit-box-reflect: below 8px linear-gradient(transparent, white);

This gradient acts as a mask:

  • Transparent areas hide the reflection
  • Opaque areas keep it visible

When I started experimenting with this, the result changed completely: the reflection stops looking "flat" and starts to look much more natural.

Creating reflections in CSS step by step with examples

Basic reflection of an image

The simplest possible use:

img { -webkit-box-reflect: below;}

This creates an immediate reflection, without separation or gradient.

Reflection with custom separation

Adding a small offset:

img { -webkit-box-reflect: below 10px;}

This adjustment is key so that the reflection does not visually interfere with the original element.

Reflection with blur effect using linear-gradient

For a more realistic finish:

img { -webkit-box-reflect: below 10px linear-gradient(transparent, rgba(255, 255, 255, 0.4));}

This is where the power of the property is truly appreciated. In my tests, combining distance + gradient is what makes the difference between an amateur effect and a convincing one.

Common problems when using webkit-box-reflect

Alignment and document flow errors

One of the main drawbacks is that the reflection does not always respect the natural layout flow. If the element is not well-contained or aligned, the reflection can overflow its container.

This forced me, in more than one case, to adjust margins and containers just so that the reflection wouldn't break the design.

Visual and layout limitations

  • It cannot be animated smoothly
  • There is no independent control of the reflection
  • Support depends on the browser engine

Therefore, although the property is very convenient, it does not replace more robust solutions when the project demands it.

Alternatives to webkit-box-reflect in modern CSS

If you need full compatibility, the alternative involves:

  • Duplicating the element
  • Using transform: scaleY(-1) or rotateX(180deg)
  • Applying gradients with mask-image or opacities

It is more work, but it offers absolute control and full support.

FAQs about box-reflect CSS

  • What is -webkit-box-reflect?
    • A non-standard CSS property that creates reflections of an element in a specific direction.
  • Does box-reflect work in Firefox?
    • No, it only works in WebKit/Blink-based browsers.
  • Can it be used without the -webkit- prefix?
    • No, it currently only works with the prefix.
  • Is it recommended to use it in production?
    • Not in critical projects; yes in experimental or educational contexts.

Conclusion: when to use box-reflect CSS and final recommendations

-webkit-box-reflect is a powerful, simple, and very visual property, ideal for experimenting and learning. It allows you to create reflections in CSS with just one line of code, something difficult to match with traditional techniques.

Mind you, it must be used with judgment. Due to its non-standard nature and limited support, it is not the best option for production, but it is an excellent tool for demos, testing, and quick visual effects.

If your goal is to learn, experiment, or visually surprise, it is totally worth trying.

It explains how to create a reflection of an image using the webkit-box-reflect property, as well as its basic syntax that allows changing the position, displacement, and even the possibility of applying masks to create reflections.

I agree to receive announcements of interest about this Blog.

Andrés Cruz

ES En español