~/css/wave-generator
CSS Wave Generator
Make a wavy edge for the top or bottom of a section: set how tall the waves are, how many there are, add up to three layered waves and pick the colour. You get an inline SVG plus the CSS that pins it to the section edge.
Section content
Using the CSS Wave Generator
Why SVG for waves
A wave is a curve, and SVG draws curves crisply at any width. The path stretches horizontally with preserveAspectRatio="none", so one small SVG covers a 320px phone and a 4K monitor without blurring or a separate image for each size.
Placing the wave
The CSS positions the SVG absolutely at the top or bottom of the section, which needs position: relative. Give the wave the colour of the next section, and the two sections appear to flow into each other instead of meeting at a hard line.
Layers for depth
Two or three waves with offset phases and lower opacity behind the main one add depth, a common look on landing pages. Keep the extra layers subtle so they read as a soft echo rather than noise.
Accessibility
The wave is decoration, so the generated SVG carries aria-hidden="true" and screen readers skip it. Keep any real content inside the section, not inside the SVG.
How do I stop a gap appearing under the wave?
A thin line between the wave and the next section usually comes from sub-pixel rounding. Overlap the two by one pixel with a negative margin, or give the SVG display: block so it does not sit on the text baseline, which adds a few pixels of empty space below inline images and SVGs.
Worked example: a hero that ends in a wave
Give the hero section a solid background, choose bottom as the edge and set the wave colour to the background of the section that follows. The wave then looks as if the next section is rising into the hero. Keep the height between 60 and 120 pixels on desktop; on a phone the SVG scales with the width, so a tall wave can take up a large share of the first screen.
Frequently asked questions
Can I animate the wave?
Yes. Animate the layer with a CSS transform such as translateX on a wider SVG, or use the CSS animation generator for keyframes. Respect prefers-reduced-motion if you do.
Will the wave cause layout shift?
No. It is absolutely positioned with a fixed height, so it does not push content around as the page loads.
Can I flip the wave?
Choose Top or Bottom. The generator flips the path for you so the curve always faces into the section.
Can I use the wave between two images?
Yes, but set the wave colour to match whatever is directly below it. A wave only reads as an edge when its fill is the same colour as the neighbouring section, so over a photo it is usually better to place it on the solid section instead.
Why use an inline SVG instead of an image file?
An inline SVG has no extra request, scales without blurring and can be recoloured with CSS. A PNG would need a separate download and would look soft on high-density screens.