How to Create Wave Background using CSS?
Last Updated :
12 Jul, 2025
A wave background is a design element having wavy patterns or shapes used to add movement in the web pages. The :before
pseudo-element can be used to create a wavy background by applying it to an element and using CSS properties like clip-path
to create wave shapes.
Using :before pseudo-element
To create a wave background using the :before pseudo-element in CSS, apply it to a container. Set its position to absolute, add a background image of a wave, and adjust its size and placement to create a visually appealing effect.
html
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
padding: 0;
margin: 0;
}
.geeks {
padding: 200px;
text-align: center;
color: white;
font-family: Arial, sans-serif;
}
section {
width: 100%;
min-height: 300px;
position: relative;
z-index: 1;
}
.pattern {
background-color: #3bb78f;
background-image: linear-gradient(315deg, #3bb78f 0%, #0bab64 74%);
position: relative;
overflow: hidden;
/* Ensure no overflow from the ::before element */
}
/* Applying ::before pseudo-element for the wave effect */
.pattern:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 250px;
background: url
(https://media.geeksforgeeks.org/wp-content/uploads/20200326181026/wave3.png);
background-size: cover;
background-repeat: no-repeat;
z-index: -1; /* Keeps the wave behind the content */
}
</style>
</head>
<body>
<section class="pattern">
<div class="geeks">
<h1>Code World</h1>
</div>
</section>
</body>
</html>
Output
Wave Background