Creating a fire animation text effect with CSS is an imaginative way to bring dynamism to your content. Although it may not be the go-to choice for a conventional website, it reveals the creative potential of designing for the web. Let’s explore how we can set the text ablaze on your screen!


Crafting the Fire Animation Text Effect with CSS

Our first step is setting up the structure. Let’s breathe life into the phrase “Ignite your Design”. Here’s the HTML:

<div class="fire">Ignite your Design</div>

And now we’ll explore the corresponding CSS. We will apply a dark background for contrast, center-align the text, set the font and size, and apply a multi-layered text-shadow to give the text a fiery appearance:

body {
 background-color:#222; /* Setting dark background for visual contrast */

.fire {
 color: #f5f5f5; /* Light text color */
 text-align:center; /* Center alignment of text */
 font-family: 'Courier New', Courier, monospace; /* Monospace font */
 font-size: 80px; /* Text size */
 /* Multi-layered text-shadow for fire effect */
 0px -1px 3px #fff, /* Innermost layer - intense heat (white) */
 0px -2px 6px #FF3, /* Second layer - core of flame (yellow) */
 0px -6px 12px #F90, /* Middle layer - body of flame (orange) */
 0px -10px 20px #C33; /* Outermost layer - edges of flame (red) */

Let’s break this down further:

  • background-color:#222; – Sets the entire body’s background to a dark shade for contrast.
  • .fire – Targets the class of our element, which allows us to style our text.
  • color: #f5f5f5; – Sets the color of our text to a light grey for better visibility against the dark background.
  • text-align:center; – We align the text to the center of the page.
  • font-family: 'Courier New', Courier, monospace; – We define the font and chose a monospace font for its uniformity and simplicity.
  • font-size: 80px; – Sets the text size to be large and noticeable.
  • Crucially, the text-shadow property is where the magic happens. It creates multiple layers of shadows in different colors, which we perceive as a flame effect. The colors range from white (the hottest part of a flame) to red (the coolest), simulating a realistic flame gradient.

Bringing the Fire Animation to Life

Next, we’ll animate the text using the @keyframes rule to vary the text-shadow, creating a flickering fire effect:

/* Define the animation named "flicker" */
@keyframes flicker {
    /* Initial state of animation */
    /* Final state of animation */
    100% { 
            0 -1px 3px #fff, /* Innermost layer - intense heat (white) */
            0 -2px 6px #FF3, /* Second layer - core of flame (yellow) */
            0 -6px 12px #F90, /* Middle layer - body of flame (orange) */
            0 -10px 20px #C33; /* Outermost layer - edges of flame (red) */
    /* Middle state of animation */
    50% { 
            0 -2px 6px #fff, /* Innermost layer - intense heat (white) */
            0 -4px 12px #FF3, /* Second layer - core of flame (yellow) */
            0 -8px 16px #F90, /* Middle layer - body of flame (orange) */
            0 -12px 24px #C33; /* Outermost layer - edges of flame (red) */

.fire {
    /* Apply the "flicker" animation to the .fire class */
    animation: flicker 2s infinite;

Here’s the explanation:

  • @keyframes flicker – Here we declare the animation with the name “flicker”. Everything enclosed in the curly braces {} defines the progression of the animation.
  • 0%, 100% {...} and 50% {...} – These are the keyframes of the animation. They specify the state of the animation at specific points in time. At the start and end of the animation (0% and 100%), the text-shadow has a smaller blur radius, and in the middle (50%), the blur radius is larger. This variance gives the illusion of a flickering flame.
  • .fire { animation: flicker 2s infinite; } – This applies our animation to the .fire class. flicker is the name of the animation, 2s is the duration of one cycle, and infinite means it will repeat indefinitely.

See the Pen
by 1stWebDesigner (@firstwebdesigner)
on CodePen.0

Fire Animation – More than Just Aesthetic Appeal

We’ve just conjured up a fire animation text effect using simple CSS!

However, our guide isn’t just about crafting a visually pleasing effect. It’s an educational journey into CSS’s dynamic features like text-shadow and @keyframes, showcasing their ability to create captivating visuals. The goal is to illustrate how simple lines of code can birth engaging visual effects.

Keep pushing boundaries and ignite your web design journey!

This post may contain affiliate links. See our disclosure about affiliate links here.