Create a Guestbook using HTML CSS and JavaScript Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report This article will show how to create a GuestBook using HTML, CSS, and JavaScript that allows users to add their name, mobile number, room number, and address to the guestbook. We have written a code that generates a card with multiple input boxes and a submit button to store the guest's information in the guestbook. PreviewApproachFirst create an HTML card and center in the window, including multiple "input" boxes and a "submit" button to store guest information.Create a CSS file to style your guestbook form. Style the form, input fields, and guestbook entries to make it visually appealing.Create a JavaScript file to handle form submissions. Add dynamically guestbook entries to the webpage with the use of innerHTML.Example: This example describes the basic implementation to create a guestbook using HTML, CSS, and JavaScript. JavaScript const guestForm = document.getElementById('guestForm'); const guestList = document.getElementById('guestList'); guestForm.addEventListener('submit', function (e) { e.preventDefault(); const name = document.getElementById('name').value; const address = document.getElementById('address').value; const mobile = document.getElementById('mobile').value; const roomno = document.getElementById('roomno').value; const guestCard = document.createElement('div'); guestCard.classList.add('guest-card'); guestCard.innerHTML = ` <h2>${name}</h2> <p><strong>Address:</strong> ${address}</p> <p><strong>Mobile:</strong> ${mobile}</p> <p><strong>Room Number:</strong> ${roomno}</p>`; guestList.appendChild(guestCard); guestForm.reset(); }); HTML <!-- index.html --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Guestbook</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>GuestBook</h1> <form id="guestForm"> <div class="form-input"> <label for="name">Name:</label> <input type="text" id="name" name="name" required> </div> <div class="form-input"> <label for="address">Address:</label> <input type="text" id="address" name="address" required> </div> <div class="form-input"> <label for="mobile">Mobile:</label> <input type="tel" id="mobile" name="mobile" required> </div> <div class="form-input"> <label for="roomno"> Room Number: </label> <input type="text" id="roomno" name="roomno" required> </div> <div class="btn"><button type="submit"> Add Guest </button></div> </form> <div id="guestList"></div> </div> <script src="script.js"></script> </body> </html> CSS /* style.css */ body { background-color: green; justify-content: center; display: flex; align-items: center; height: 100vh; font-family: Arial, sans-serif; } .container { width: 400px; padding: 20px; background-color: #fff; border-radius: 8px; } .container h1 { text-align: center; } .form-input { margin-bottom: 11px; } .form-input label { display: block; margin-bottom: 5px; } .form-input input { width: 80%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; } .btn button { cursor: pointer; background-color: #007BFF; transition: background-color 0.4s ease; color: #fff; border: none; padding: 10px 20px; border-radius: 3px; font-size: 12px; } .guest-card { border: 1px solid #ccc; padding: 5px; margin: 5px 0; background-color: #fff; border-radius: 5px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); } .btn button:hover { background-color: #394b5e; } .guest-card h2 { margin: 0; } .guest-card p { margin: 5px 0; } Output: Output Comment More infoAdvertise with us Next Article Create a Guestbook using HTML CSS and JavaScript S subramanyasmgm Follow Improve Article Tags : JavaScript JavaScript-Projects Geeks Premier League 2023 Similar Reads How to create a Color Generator using HTML CSS and JavaScript ? In this article, we will develop a Color Generator application using HTML, CSS, and JavaScript.In this application, we have created the Multi Format color generator. Users can select Colour Types like RGB, HEX, and CMYK. Use the sliders to customize the color and Inout field in case of HEX and color 6 min read Create GeeksforGeeks Clone Using HTML CSS & JavaScript In this article, we'll make a clone of the GeeksforGeeks website. The clone includes home, about, courses, and contact pages. On the home page, we've added sections like categories, features, testimonials, and FAQs, similar to the GFG website. We named our clone GeeksforGeeks 2.0 to avoid copyright 15+ min read Create a Health Tracker using HTML CSS & JavaScript In this article, we will see how we can create a health tracker using HTML, CSS, and JavaScript.Here, we have provided the user with three inputs i.e. input water intake, exercise duration, and blood sugar levels. The user can input these daily and then the provided data is stored in the localStorag 5 min read How to create a Landing page using HTML CSS and JavaScript ? A landing page, also referred to as a lead capture page, static page, or destination page, serves a specific purpose and typically appears as a result of online advertising or search engine optimization efforts. Unlike a homepage, a landing page is stripped of distractions and focuses on capturing v 7 min read Design a Tip Calculator using HTML, CSS and JavaScript The tip is the money given as a gift for good service to the person who serves you in a restaurant. In this project, a simple tip calculator is made that takes the billing amount, type of service, and the number of persons as input. As per the three inputs, it generates a tip for the serving person. 4 min read Create an QR Code Generator Project using HTML CSS & JavaScript Today, more than 75% of websites and apps use QR codes to share links, contact info, or event details quickly. Here, youâll learn how to make your own QR Code Generator using HTML, CSS, and JavaScript. Weâll guide you step by step, so even if youâre a beginner, you can follow along easily. By the en 3 min read Create a Data Export and Import using HTML CSS and JavaScript In this article, we are going to implement a Data Export and Import Project using HTML CSS & JavaScript. The application we are going to create will allow the user to export their data to a CSV file effortlessly and then import data back from CSV files. Whether you're managing lists or working w 3 min read How to Create a Portfolio Website using HTML CSS and JavaScript ? A portfolio website is a website that represents you online on the web pages. It contains different sections like Introduction to Yourself, About You, Your Services, Your Contact Details, and Your Portfolio. We are going to build all of the sections with an interactive and attractive web design that 15+ min read Dynamic Resume Creator using HTML CSS and JavaScript Creating a well-structured and professional resume can be time-consuming and difficult for many job seekers. Challenges like formatting, organizing details, and making the resume stand out are common. To solve this issue, a Resume Creator project was developed to simplify the process by offering an 5 min read How to create a revealing sidebar using HTML CSS and JavaScript? A revealing sidebar is a hidden UI element that becomes visible upon user interaction, such as clicking or swiping, providing navigation links. The content of the page will rotate and the navigation bar will reveal itself when the menu button is clicked. ApproachCreate an HTML file with headings and 3 min read Like