---
title: "Blend Difference"
description: "Auto-inverting captions using mix-blend-mode: difference — text flips between white and black per-pixel against the background"
---
# Blend Difference
Auto-inverting captions using mix-blend-mode: difference — text flips between white and black per-pixel against the background
`text` `effect` `blend-mode` `contrast` `inversion`
## Install
```bash Terminal
npx hyperframes add caption-blend-difference
```
## How It Works
White text with `mix-blend-mode: difference` inverts per-pixel against whatever is behind it:
- **Dark background** → text stays white
- **Light background** → text flips to black
- **Color background** → text becomes the complement (blue → orange, red → cyan)
The composition root needs `isolation: isolate` so the blend operates against sibling content (video, images) rather than the page background.
## Variants
| Class | Blend Mode | Effect |
| --- | --- | --- |
| `.blend-difference` | `difference` | Hard per-pixel inversion — maximum contrast |
| `.blend-difference-soft` | `exclusion` | Softer inversion — less harsh on midtones |
| `.blend-difference-screen` | `screen` | Text glows on dark areas, fades on light |
## Example
```html
```
## CSS Custom Properties
| Property | Default | Description |
| --- | --- | --- |
| `--blend-caption-color` | `white` | Base text color before blending |
| `--blend-mode` | `difference` | Override blend mode on `.blend-difference` |
## Details
| Property | Value |
| --- | --- |
| Type | Component |
## Files
| File | Target | Type |
| --- | --- | --- |
| `caption-blend-difference.html` | `compositions/components/caption-blend-difference.html` | hyperframes:snippet |
## Usage
Open `compositions/components/caption-blend-difference.html` and paste its contents into your composition. See the comment header in the file for detailed instructions.