<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/falling-snow-effect-with-html-css-and-javascript-gfhf9xrlu" -->

---
title: Falling Snow Effect with HTML, CSS, and JavaScript
description: You can add falling snow to any page by pasting one HTML element, some CSS, and a script just above the closing body tag. The script clones a single snowflake...
canonical: https://daily.dev/posts/falling-snow-effect-with-html-css-and-javascript-gfhf9xrlu
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Falling Snow Effect with HTML, CSS, and JavaScript | daily.dev
og:description: You can add falling snow to any page by pasting one HTML element, some CSS, and a script just above the closing body tag. The script clones a single snowflake...
og:url: https://daily.dev/posts/falling-snow-effect-with-html-css-and-javascript-gfhf9xrlu
og:image: https://api.daily.dev/og/posts/GFhF9XRlu.png
og:image:alt: Falling Snow Effect with HTML, CSS, and JavaScript
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Falling Snow Effect with HTML, CSS, and JavaScript

**[Kirupa](https://daily.dev/sources/kirupa)** · 29 min read · 1 upvotes · 0 comments

## Summary

You can add falling snow to any page by pasting one HTML element, some CSS, and a script just above the closing body tag. The script clones a single snowflake element, then gives each clone its own opacity, speed, and position. A requestAnimationFrame loop moves each flake with sine and cosine math, using the time between frames so speed stays the same on 60Hz and 120Hz screens. The snow stops for reduced-motion users and hidden tabs. A few hundred flakes are usually fine, but thousands call for a canvas. The code is MIT licensed.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.kirupa.com/html5/the_falling_snow_effect.htm>

## Questions this post answers

### How do I keep a requestAnimationFrame animation at the same speed on 60Hz and 120Hz displays?

Scale each frame's movement by a delta value. Subtract the previous frame's timestamp from the current one and divide by the length of a 60fps frame (about 16.67 milliseconds). That gives about 1 on 60Hz and about 0.5 on 120Hz. Capping delta at 3 stops a long hiccup from making elements jump.

_Developers tuning smooth web animations follow this kind of technique on daily.dev._

### How do I respect prefers-reduced-motion in a JavaScript animation and let users stop it?

Check matchMedia('(prefers-reduced-motion: reduce)'), set an enableAnimations flag from it, and hide the animated container and cancel the animation loop when it matches. Listen for the query's change event so toggling the setting works without a reload. Add a stop button that flips the same flag for users who don't know the setting.

_Anyone shipping accessible web animation can keep up with these patterns on daily.dev._

### How many DOM elements can I animate before I should switch to canvas for a particle effect?

A few hundred animated DOM elements are usually fine on a modern laptop or phone, as long as only transform and opacity change. Once you want thousands, each particle being its own DOM element starts to cost performance, and drawing them on a canvas becomes the better fit.

_Developers weighing DOM against canvas for animation can follow that debate on daily.dev._

## Similar posts on daily.dev

- [snow simulation toy](https://daily.dev/posts/snow-simulation-toy-zovadkjzs) · Hacker News · 0 upvotes · 1 comments
- [Let it snow](https://daily.dev/posts/let-it-snow-tpqpufsz8) · Blogging and all that Malarkey · 0 upvotes · 0 comments
- [Artist Shares Real-Time Snowfall System Built with Three.js & WebGL](https://daily.dev/posts/artist-shares-real-time-snowfall-system-built-with-three-js-webgl-doulzeo8m) · 80 LEVEL · 0 upvotes · 0 comments
- [Bouncing Square Animation With Random Colors in JavaScript](https://daily.dev/posts/bouncing-square-animation-with-random-colors-in-javascript-tmiq6kkev) · Kirupa · 3 upvotes · 0 comments
- [Icon Fall Web Component—zachleat.com](https://daily.dev/posts/icon-fall-web-component-zachleat-com-dsf5ljgxg) · Zach Leatherman · 12 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#css](https://daily.dev/tags/css), [#html](https://daily.dev/tags/html), [#accessibility](https://daily.dev/tags/accessibility)

[View this post on daily.dev](https://daily.dev/posts/falling-snow-effect-with-html-css-and-javascript-gfhf9xrlu)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Falling Snow Effect with HTML, CSS, and JavaScript","url":"https://daily.dev/posts/falling-snow-effect-with-html-css-and-javascript-gfhf9xrlu","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/falling-snow-effect-with-html-css-and-javascript-gfhf9xrlu"},"datePublished":"2026-11-28T06:30:38.175Z","dateModified":"2026-11-28T06:31:03.614Z","description":"You can add falling snow to any page by pasting one HTML element, some CSS, and a script just above the closing body tag. The script clones a single snowflake...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/25dc64508444b3a4fb0e3bc986305bf4?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/25dc64508444b3a4fb0e3bc986305bf4?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Kirupa","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Kirupa","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ff2fdb4927d34b81bd07cd18d6049a98","url":"https://daily.dev/sources/kirupa"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/falling-snow-effect-with-html-css-and-javascript-gfhf9xrlu","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,css,html,accessibility","timeRequired":"PT29M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Kirupa","item":"https://daily.dev/sources/kirupa"},{"@type":"ListItem","position":3,"name":"Falling Snow Effect with HTML, CSS, and JavaScript"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/falling-snow-effect-with-html-css-and-javascript-gfhf9xrlu#faq","mainEntity":[{"@type":"Question","name":"How do I keep a requestAnimationFrame animation at the same speed on 60Hz and 120Hz displays?","acceptedAnswer":{"@type":"Answer","text":"Scale each frame's movement by a delta value. Subtract the previous frame's timestamp from the current one and divide by the length of a 60fps frame (about 16.67 milliseconds). That gives about 1 on 60Hz and about 0.5 on 120Hz. Capping delta at 3 stops a long hiccup from making elements jump. Developers tuning smooth web animations follow this kind of technique on daily.dev."}},{"@type":"Question","name":"How do I respect prefers-reduced-motion in a JavaScript animation and let users stop it?","acceptedAnswer":{"@type":"Answer","text":"Check matchMedia('(prefers-reduced-motion: reduce)'), set an enableAnimations flag from it, and hide the animated container and cancel the animation loop when it matches. Listen for the query's change event so toggling the setting works without a reload. Add a stop button that flips the same flag for users who don't know the setting. Anyone shipping accessible web animation can keep up with these patterns on daily.dev."}},{"@type":"Question","name":"How many DOM elements can I animate before I should switch to canvas for a particle effect?","acceptedAnswer":{"@type":"Answer","text":"A few hundred animated DOM elements are usually fine on a modern laptop or phone, as long as only transform and opacity change. Once you want thousands, each particle being its own DOM element starts to cost performance, and drawing them on a canvas becomes the better fit. Developers weighing DOM against canvas for animation can follow that debate on daily.dev."}}]}
```

