You will build the classic “Star Wars” opening text crawl with pure HTML and CSS: the blue intro line, the yellow tilted crawl that tapers into the distance, a subtle starfield, and a soft fade at the top. By the end, you will have a reusable component that works without JavaScript and is easy to theme, slow down, or speed up.
Why a Star Wars Text Crawl Matters
This pattern teaches several valuable CSS techniques in one focused project. You will set up a 3D perspective, tilt a plane with rotateX, translate it over time with keyframes, and layer a gentle top fade. You will learn to organize CSS with custom properties so color palettes and timing can change in one place. You will also see how to create a starfield without images, and how to respect prefers-reduced-motion so the effect remains usable.
Prerequisites
You only need foundational CSS and a willingness to experiment with transforms and animations. If you understand the pieces below, you will be right at home.
- Basic HTML
- CSS custom properties
- CSS pseudo-elements (::before / ::after)
Step 1: The HTML Structure
The markup separates the starfield, an intro line, and the crawl. The crawl has a perspective wrapper, a mask for the top fade, and a text block that holds the title, episode, headline, and body paragraphs. A small checkbox-label pair gives you a “Replay” toggle without JavaScript.
<!-- HTML -->
<div class="space-crawl">
<!-- Starfield layers (decorative) -->
<div class="space-crawl__stars" aria-hidden="true"></div>
<div class="space-crawl__stars space-crawl__stars--layer2" aria-hidden="true"></div>
<!-- Intro line -->
<p class="intro-line" aria-hidden="true">A long time ago in a galaxy far, far away...</p>
<!-- Replay control (pure CSS) -->
<input type="checkbox" id="replay" class="replay-toggle" hidden>
<label for="replay" class="replay-btn" aria-label="Replay the crawl">Replay</label>
<!-- The crawl -->
<section class="crawl" aria-label="Star Wars style opening crawl">
<div class="crawl__mask" aria-hidden="true"></div>
<div class="crawl__perspective">
<div class="crawl__text">
<p class="crawl__title">STAR WARS</p>
<p class="crawl__episode">Episode IV</p>
<p class="crawl__headline">A NEW HOPE</p>
<p>It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire.</p>
<p>During the battle