CSS Wave Shape: Wavy Section Dividers and Backgrounds
Wavy edges between page sections are a quick way to make a site feel less boxy. There are two good ways to make a CSS wave shape: a small inline SVG (the most flexible, and the usual choice for section dividers) or pure CSS with radial-gradient, for repeating, even scallops.
Demo:
Section with a wavy bottom edge
Wavy section divider with SVG
Put a small SVG at the bottom of the section and fill it with the next section’s background color. preserveAspectRatio="none" stretches the wave to any width. Change the path’s curve points to change the wave, or stack two paths with different opacity for a layered look.
<section class="hero">
<h1>Welcome</h1>
<svg class="divider" viewBox="0 0 1200 120" preserveAspectRatio="none" aria-hidden="true">
<path d="M0,60 C200,120 400,0 600,60 C800,120 1000,0 1200,60 L1200,120 L0,120 Z"></path>
</svg>
</section>
<style>
.hero { position: relative; padding-bottom: 100px; background: #1d4ed8; }
.divider {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 80px;
fill: #ffffff; /* next section's background */
}
</style>
Pure CSS scalloped edge
For an even, repeating wave without SVG, hang a row of half-circles below the box: a radial-gradient circle in the box’s color, repeated along a pseudo-element. Change --size to make the waves bigger or smaller. It works on solid colors; for photos or gradients, use the SVG divider above.
.wavy {
--size: 12px;
position: relative;
margin-bottom: var(--size);
background: #3b82f6;
}
.wavy::after {
content: "";
position: absolute;
left: 0;
right: 0;
top: 100%;
height: var(--size);
background: radial-gradient(circle at 50% 0, #3b82f6 var(--size), transparent calc(var(--size) + 0.5px))
0 0 / calc(var(--size) * 2) var(--size) repeat-x;
}
Animated wave
Make the SVG twice as wide as its container with a repeating wave, then slide it sideways. Because the wave repeats, moving it by exactly half its width loops seamlessly.
.wave-track {
position: absolute;
bottom: 0;
width: 200%;
height: 80px;
animation: wave-slide 8s linear infinite;
}
@keyframes wave-slide {
to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
.wave-track { animation: none; }
}
FAQ
How do I make a wave shape in CSS?
For a section divider, use an inline SVG wave at the bottom of the section, filled with the next section’s color. For a repeating, even scalloped edge, use a radial-gradient on a pseudo-element.
How do I make the wave flip upside down?
Add transform: scaleY(-1) to the SVG and place it at the top of the next section instead.
Why is there a thin line between the wave and the next section?
Sub-pixel rounding. Move the SVG down 1px (bottom: -1px) so it overlaps the next section slightly.
Related: CSS blob shape, CSS gradient generator, position absolute vs relative and CSS tips.