CSS

CSS Overview Selectors Declarations Rule Sets Comments Reset/Normalize Origin Importance Order Specificity Inheritance Cascade Layers Inline Styles Internal Styles External Styles @import Absolute Units Relative Units Dynamic Viewport Angle Units Time Units Frequency Units: Resolution Units Keywords Color Formats Color Functions & Spaces Background Color Background Image Background Repeat Background Position Background Size Background Attachment Background Shorthand Multiple Backgrounds Linear Gradients Radial Gradients Conic Gradients Font Family Font Size Font Weight Font Style Line Height Text Align Text Decoration Text Transform Letter Spacing Word Spacing Text Shadow Text Wrap Variable Fonts Content Box Padding Box Border Box Margin Box Box Sizing Property Margin Padding Border Outline Box Shadow Block Display Inline Display Inline Block Display Static Position Relative Position Absolute Position Fixed Position Sticky Position Top Element Position Right Element Position Bottom Element Position Left Element Position Z Index Flexbox Box Layout Display Flex Flex Direction Flex Wrap Justify Content Align Items Align Content Gap, Row Gap & Column Gap Flex Grow Flex Shrink Flex Basis Flex Shorthand Order Property Align Self Practical Applications CSS Grid Layout Grid Display Grid Template Columns Grid Template Rows Grid Template Areas Justify Items Grid Auto Columns Justify Self Nested Grids Responsive Web Design Min Width Max Width Orientation Logical Operators Pointer Hover Prefers Color Scheme Fluid Images Flexible Typography Viewport Width Advanced CSS Features Defining variables Using variables Scope & Inheritance of CSS Variables Property Value Fallback Practical Applications :Hover :Active :Focus :Focus Visible :Visited :Link :First Child :Last Child :Nth Child :Nth of Type :Empty :Checked :Disabled :Enabled :Valid :Invalid :Required :Has :Not :Is :Where ::Before Pseudo Element ::After Pseudo Element ::First Letter ::First Line ::Selection ::Marker CSS 2D Transformations CSS 3D Transformations Transform Origin Transform Style Backface Visibility Transition Property Transition Duration Transition Timing Function Transition Delay Transition Shorthand Ease Timing Function Linear Timing Function Ease In Timing Function Ease Out Timing Function Ease In Out Timing Function Cubic Bezier Function Animations (@keyframes) Defining @keyframes Animation Name CSS Animation Duration Animation Timing Function CSS Animation Delay CSS Animation Iteration Count Animations Direction CSS Animation Fill Mode CSS Animation Play State CSS Filter Blur CSS Filter Brightness CSS Filter Contrast() CSS Drop Shadow CSS Grayscale CSS Hue Rotate CSS Invert CSS Opacity CSS Saturate CSS Sepia Mix Blend Mode Background Blend Mode Object Fit & Object Position Scroll Snap Type Scroll Snap Align Scroll Padding Scroll Margin Scroll Triggered Animations JS Variables

CSS Sepia


The CSS filter property applies graphical effects like blurring or color shifting to an element. The sepia() function specifically adds a sepia tone to an image, making it appear warmer and more old-fashioned. The effect's intensity can be controlled by a value, where 1 or 100% represents a full sepia effect, and 0 or 0% leaves the image unchanged.


Example 1: Basic Sepia Effect

HTML

<img class="sepia-basic" src="image.jpg" alt="A landscape">

CSS

/* Applies a full sepia effect to the image */
.sepia-basic {
  filter: sepia(100%);
}

Explanation:

This code applies a complete sepia effect to the image with the class sepia-basic. The sepia(100%) value converts all the colors in the image to their corresponding sepia tones, creating a classic, aged photograph look.


Example 2: Partial Sepia Effect

HTML

<img class="sepia-partial" src="image.jpg" alt="A portrait">

CSS

/* Applies a 50% sepia effect to the image */
.sepia-partial {
  filter: sepia(0.5);
}

Explanation:

Here, the sepia(0.5) function is used to apply a half-strength sepia filter. This results in a less intense, more subtle vintage effect compared to a full 100% value.


Example 3: Sepia on Hover

HTML

<img class="sepia-hover" src="image.jpg" alt="Cityscape">

CSS

/* Smoothly transitions to a sepia effect on hover */
.sepia-hover {
  transition: filter 0.3s ease-in-out;
}

.sepia-hover:hover {
  filter: sepia(1);
}

Explanation:

This example demonstrates a common interactive effect. The image appears normal initially, but when the user hovers their mouse over it, a sepia filter is smoothly applied over 0.3 seconds.


Example 4: Combining Sepia with Other Filters

HTML

<img class="sepia-combined" src="image.jpg" alt="A flower">

CSS

/* Applies both a sepia and a brightness filter */
.sepia-combined {
  filter: sepia(0.8) brightness(1.1);
}

Explanation:

The filter property allows for multiple functions to be chained together. In this case, an 80% sepia effect is combined with a 10% increase in brightness, creating a unique, stylized look.


Example 5: Sepia on a Video Element

HTML

<video class="sepia-video" controls>
  <source src="movie.mp4" type="video/mp4">
</video>

CSS

/* Applies a sepia effect to a video element */
.sepia-video {
  filter: sepia(90%);
}

Explanation:

The filter property is not limited to images. This code shows how to apply a 90% sepia effect directly to an HTML5 video, giving the entire playback a vintage film aesthetic.


Example 6: Using calc() with Sepia

HTML

<img class="sepia-calc" src="image.jpg" alt="An animal">

CSS

/* Uses calc() to determine the sepia intensity */
.sepia-calc {
  filter: sepia(calc(0.25 * 2)); /* results in sepia(0.5) */
}

Explanation:

This demonstrates using the calc() function within the sepia() filter. While simple in this case, calc() can be used for more complex calculations, potentially involving CSS variables for dynamic themeing.


Example 7: Sepia Filter on Text

HTML

<div class="sepia-text">
  <h1>Vintage Heading</h1>
</div>

CSS

/* Applies a sepia filter to a parent container */
.sepia-text {
  filter: sepia(0.7);
  background-color: #fff; /* A background is needed for the filter to apply */
  display: inline-block; /* Ensures the filter wraps the content */
  color: #222;
}

Explanation:

This example applies a sepia filter to a div element containing text. For the filter to affect the text's color, the element needs a background. The sepia effect will tint both the background and the text content.