How to create a Blur Mask Image Website using HTML CSS and JavaScript ? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In this article, we will see how to create a website with a blur mask image using HTML, CSS, and JavaScript. Generally, we often see this kind of effect on many websites. When clicking the button, the box immediately becomes hidden, displaying the blurred content. The website is responsive and works well on every screen size. PreviewOutputApproachCreate a navbar using the semantic tag <nav>. Create a home, about, and contact us links in that section and style all of them in a CSS file like display, gap, height, etc.Now create a body section and write the main content of a website.To give a blur effect we have used a property filter with value blur(5px). We have also used media queries to make the website responsive.Initialize a variable and by using template literals we will give some properties that we want to change dynamically when the user clicks the click here button.Now target a particular element and apply it to the event listener for the functionality of click, and give style. Example: The example illustrates the implementation of blur mask images using HTML, CSS, and JavaScript. HTML <!-- index.html --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <title>Blur effect</title> </head> <body> <div class="container"> <!-- NavBar --> <nav class="navbar"> <div class="logo"> <h3 class="textgfg"> GeeksforGeeks </h3> </div> <div class="nav-links"> <div class="home"> <a href="#">Home</a> </div> <div class="about"> <a href="#">About</a> </div> <div class="contactus"> <a href="#">Contact US</a> </div> </div> </nav> <!-- Main content shows here and blur after click --> <div class="main-section" id="blureffect"> <div class="content-container"> <h3>HTML</h3> <p> Html stands for Hypertext markup language. It is used to create a basic structure of any website. </p> <h3>CSS</h3> <p> Css stands for cascading style sheet. It is used to give styles to a html element to make website beautiful. There are many properties like colors, positioning, fonts. </p> <h3>JavaScript</h3> <p> JavaScript is a scripting language. It is popular for it's dynamic nature and other features which makes website user-interactive. We can write JavaScript in Html file. </p> </div> </div> </div> <div class="upperdiv" id="upperdivid">Click here</div> <!-- Footer section --> <div class="footertext"> All rights are reserved to the respective owner </div> <script src="script.js"></script> </body> </html> CSS /* style.css*/ @import url( 'https://fonts.googleapis.com/css2?family=Poppins&display=swap'); * { margin: 0; padding: 0; box-sizing: border-box; overflow: hidden; font-family: 'Poppins', sans-serif; } /* Styles for Navbar */ .navbar { display: flex; justify-content: center; align-items: center; height: 10vh; width: 100vw; background-color: olivedrab; justify-content: space-around; overflow: hidden; } /* Styles for main-section */ .main-section { background-color: bisque; height: 80vh; display: flex; justify-content: center; overflow: hidden; filter: blur(5px); } .content-container { max-width: 1180px; text-align: center; font-size: 20px; gap: 40px; display: flex; flex-direction: column; overflow: hidden; cursor: pointer; padding: 10px; } /* Properties for GeeksforGeeks */ .textgfg { color: rgb(7, 68, 7); font-size: 28px; } .nav-links { display: flex; gap: 50px; } a { color: rgb(238, 225, 225); font-size: larger; text-decoration: none; } /* Style for footer */ .footertext { height: 10vh; background-color: olivedrab; text-align: center; padding: 30px; font: 20px; } .upperdiv { background-color: rgb(170, 206, 99); height: 12vh; width: 25vw; position: absolute; top: 40vh; left: 40vw; border: 5px solid green; border-radius: 80px; text-align: center; padding: 12px; font-weight: 700; font-size: 25px; } /* Media queries for responsiveness */ @media only screen and (max-width: 608px) { .content-container { font-size: 10px; padding: 15px; } .footertext { text-align: center; padding: 10px; font: 20px; } .nav-links { display: flex; gap: 5vw; } a { font-size: 10px; } .textgfg { font-size: 18px; } .upperdiv { padding: 1.5vw; font-size: 15px; } } @media (max-width: 827px) and (min-width:608px) { .content-container { font-size: 15px; padding: 10px; } .footertext { text-align: center; padding: 10px; font: 20px; } } JavaScript // script.js let styles = `display: none;`; let stylemaincontent = `filter: blur(0);` const frontbox = document.getElementById("upperdivid"); const mainContent = document.getElementById("blureffect"); frontbox.addEventListener("click", () => { frontbox.style = styles; mainContent.style = stylemaincontent; }) Output: Output Comment More infoAdvertise with us Next Article How to create a Blur Mask Image Website using HTML CSS and JavaScript ? S shivanigupta18rk Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Projects Similar Reads How to Create Image Magnifier using HTML CSS and JavaScript? An image magnifier is a feature that allows users to zoom into specific parts of an image, simulating a magnifying glass effect. Itâs created using HTML for structure, CSS for styling, and JavaScript to control the zoom functionality dynamically on hover or click.There are two methods to create an i 2 min read How to Create Image Lightbox Gallery using HTML CSS and JavaScript ? A lightbox gallery is basically used to view the gallery images in detail specifically. You can code the JavaScript to do so but also we can use some downloaded JS and CSS. In this article, we will download the lightbox and attach the JS and CSS files into our code. For our own design satisfaction, 3 min read How To Create a Thumbnail Image using HTML and CSS ? The thumbnail image is used to add a 1px rounded border around the image. A thumbnail is a small size image that represents a larger image. The thumbnail is the image that is displayed as a preview of the video. It is used to represent what the video contains or what it is related to. It is displaye 1 min read Create an Image Background Remover App Using HTML CSS & JavaScript Building an Image Background Remover using HTML, CSS, and JavaScript demonstrates the power of combining these technologies to create interactive and user-friendly applications. The clean design and intuitive features make this tool not only functional but also enjoyable for users to interact with. 3 min read How to randomly change image color using HTML CSS and JavaScript ? In this article, we will create a webpage where we can change image color randomly by clicking on the image using HTML, CSS, and JavaScript. The image color will change randomly using the JavaScript Math random() function.Approach:First of all select your image using HTML <img> tag.In JavaScri 2 min read How to Create an Image Overlay Icon using HTML and CSS ? Image overlay Icon can be an impressive addition to interactive detail or a set of features for your website. This article content will divide the task into two sections, the first section creating the structure and attach the link for the icon. In the second section, we will design the structure us 3 min read Create a Resize and Compress Images in HTML CSS & JavaScript While using the GeeksforGeeks Write Portal to write articles, we need to upload the images. As we need to resize the image as per GeeksforGeeks's requirement, we search for different tools and websites on the internet to resize and compress the image. But, as a web developer, we can create our own i 7 min read How to create Image Stack Illusion using HTML and CSS ? In this article, we are going to create an illusion of images below the main image. It is the same as the image set of the gallery in an older version of Android. This is a simple project, we can achieve our target only by using HTML AND CSS.Overview of the project:Approach:Create a main div in whic 3 min read How to create a Hero Image using HTML and CSS ? A Hero Image is a large image with text, often placed at the top of a webpage. Hero images can be designed using HTML and CSS. This article contains two sections. The first section attaches the image and designs the basic structure. The second section designs the images and texts on the images. The 2 min read How to Create an Image Element using JavaScript? Creating an image element dynamically using JavaScript is a useful technique when you want to add images to a webpage without having to manually write the <img> tag in your HTML. This allows for more flexibility, as we can create and manipulate images based on user interactions or other condit 2 min read Like