How to Make a Cookie Clicker Using HTML and JavaScript? Last Updated : 18 Oct, 2024 Comments Improve Suggest changes Like Article Like Report Creating a "Cookie Clicker" game is a great beginner project for learning how to manipulate elements in HTML with JavaScript. The idea is simple: a user clicks on a cookie image, and each click increases the score. We can add more features like auto-clickers, upgrades, or score multipliers, but we'll start with a basic version to understand the core concepts.ApproachCreate elements for displaying the score and a clickable cookie image.Make the game visually appealing by styling the cookie, score display, and background.Use JavaScript to increase the score every time the user clicks on the cookie.Add a function to reset the score back to zero when the reset button is clicked.Enhance the game with simple animations, such as scaling the cookie when clicked.Example: This example shows the design of a cookie clicker game using HTML CSS and JavaScript. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Cookie Clicker Game</title> <style> /* Game styling */ body { text-align: center; font-family: 'Arial', sans-serif; background-color: #f0e6d6; margin-top: 50px; } h2 { font-size: 32px; color: #5e3d0c; } #cookie { width: 200px; height: 200px; background-color: #d2691e; border-radius: 50%; display: inline-block; cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; position: relative; box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); } #cookie:active { transform: scale(0.9); box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.2); } .chocolate-chip { width: 18px; height: 18px; background-color: #4b2e1f; border-radius: 50%; position: absolute; } /* Chip positions */ .chip1 { top: 30px; left: 60px; } .chip2 { top: 70px; right: 50px; } .chip3 { bottom: 40px; left: 80px; } .chip4 { top: 100px; left: 110px; } .chip5 { bottom: 30px; right: 60px; } .chip6 { top: 40px; right: 80px; } .chip7 { bottom: 80px; left: 40px; } #score { font-size: 28px; font-weight: bold; margin: 20px 0; color: #5e3d0c; } button { padding: 12px 24px; font-size: 18px; cursor: pointer; background-color: #8b4513; color: white; border: none; border-radius: 8px; margin-top: 20px; transition: background-color 0.3s; } button:hover { background-color: #a0522d; } </style> </head> <body> <h2>Cookie Clicker Game</h2> <p>Score: <span id="score">0</span></p> <div id="cookie"> <div class="chocolate-chip chip1"></div> <div class="chocolate-chip chip2"></div> <div class="chocolate-chip chip3"></div> <div class="chocolate-chip chip4"></div> <div class="chocolate-chip chip5"></div> <div class="chocolate-chip chip6"></div> <div class="chocolate-chip chip7"></div> </div> <br><br> <button id="reset-button">Reset Score</button> <script> let score = 0; // Increment score on cookie click const cookie = document.getElementById('cookie'); const scoreDisplay = document.getElementById('score'); const resetButton = document.getElementById('reset-button'); cookie.addEventListener('click', () => { score++; scoreDisplay.textContent = score; }); // Reset the score resetButton.addEventListener('click', () => { score = 0; scoreDisplay.textContent = score; }); </script> </body> </html> Output:Output Comment More infoAdvertise with us Next Article How to Make a Cookie Clicker Using HTML and JavaScript? P pankaj2025 Follow Improve Article Tags : HTML javaScript Similar Reads HTML Tutorial HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript 11 min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read Top 10 Projects For Beginners To Practice HTML and CSS Skills Learning to code is an exciting journey, especially when stepping into the world of programming with HTML and CSSâthe foundation of every website you see today. For most beginners, these two building blocks are the perfect starting point to explore the creative side of web development, designing vis 8 min read HTML Introduction HTML stands for Hyper Text Markup Language, which is the core language used to structure content on the web. It organizes text, images, links, and media using tags and elements that browsers can interpret. As of 2025, over 95% of websites rely on HTML alongside CSS and JavaScript, making it a fundam 6 min read HTML Tags - A to Z List HTML Tags are fundamental elements used to structure and format content on web pages. They provide instructions to web browsers on how to render text, images, links, and other media.HTML tags are enclosed in angle brackets < > and usually come in pairs: an opening tag and a closing tag. The cl 15+ min read HTML DOCTYPE Declaration HTML DOCTYPE (Document Type Declaration) is an instruction that appears at the beginning of an HTML document, before the <html> tag.Its primary role is to tell the web browser which version of HTML the page is written in, ensuring that the browser renders the content correctly. It is not an HT 4 min read 30+ Web Development Projects with Source Code [2025] Web development is one of the most in-demand career paths in the IT industry, experiencing consistent growth of around 20â25% annually. Whether you're a student starting out or an experienced professional looking to switch or advance your career, it's essential to go beyond theory and demonstrate yo 4 min read Frontend Developer Interview Questions and Answers Frontend development is an important part of web applications, and it is used to build dynamic and user-friendly web applications with an interactive user interface (UI). Many companies are hiring skilled Frontend developers with expertise in HTML, CSS, JavaScript, and modern frameworks and librarie 15+ min read HTML Forms HTML forms, defined using the <form> Tags are essential for collecting user input on web pages. They incorporate a variety of interactive controls such as text fields, numeric inputs, email fields, password fields, checkboxes, radio buttons, and submit buttons. Over 85% of websites rely on for 5 min read HTML Tables HTML (HyperText Markup Language) is the standard markup language used to create and structure web pages. It defines the layout of a webpage using elements and tags, allowing for the display of text, images, links, and multimedia content. As the foundation of nearly all websites, HTML is used in over 10 min read Like