Frontend.fyi

Recipe

CSS-only text marquee

Bringing back some nostalgia

Go Pro

Playgrounds are part of PRO

Frontend.fyi Playgrounds let you take any code example and turn it into a live, editable sandbox — so you can tweak the code, build on it, and learn by doing.

This feature is part of Frontend.fyi PRO, which gives you lifetime access to:

  • Interactive playgrounds (like this one)
  • Full courses (Framer Motion, CSS, and more coming)
  • Copy-paste UI recipes with video walkthroughs
  • Your own public profile to showcase projects and experiments (soon!)

If you're ready to go beyond just watching tutorials and actually build things yourself, PRO is for you.

Marquees have been a part of the web for decades. Sadly we can’t use the <marquee> element anymore nowadays. So we have to recreate our own version of it!

How it works

The CSS based marquee makes the impression of an endlessly looping text, by duplicating its contents, and swapping the animation back to the start exactly halfway.

Because of this it is important to have the content at least duplicated once. And if you’re using the same word multiple times, you should always use an even amount. Otherwise the midpoint of the animation won’t be the same as the start.

Sounds confusing? Make sure to check the tutorial on CSS text marquees where I explain it in more detail.

Configuration

By default the marquee uses two CSS variables, so you can reuse the marquee without changing the CSS.

  • --speed - The speed of the marquee. Default is 10s.
  • --direction - The direction of the marquee. Default is forwards. Can be set to reverse to make the marquee go the other way.

Other interesting recipes

CSS FREE Recipe Using CSS masks to fadeout content

View recipe

CSS FREE Recipe CSS-only logo marquee

View recipe