<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Digital Clock with Selectable Fonts</title> <style> body { font-family: Arial, sans-serif; text-align: center; padding-top: 50px; background-color: #f0f0f0; } #clock { font-size: 4em; margin: 20px; padding: 10px; background: #fff; display: inline-block; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); } #controls { margin-bottom: 20px; } label { font-size: 1.2em; margin-right: 10px; } </style> </head> <body> <div id="controls"> <label for="fontSelector">Select Font:</label> <select id="fontSelector"> <option value="Arial" selected>Arial</option> <option value="Courier New">Courier New</option> <option value="Georgia">Georgia</option> <option value="Times New Roman">Times New Roman</option> <option value="Verdana">Verdana</option> </select> </div> <div id="clock">00:00:00</div> <script> // Function to update the clock display function updateClock() { const now = new Date(); let hours = now.getHours(); let minutes = now.getMinutes(); let seconds = now.getSeconds(); // Format time with leading zeros if needed hours = hours < 10 ? '0' + hours : hours; minutes = minutes < 10 ? '0' + minutes : minutes; seconds = seconds < 10 ? '0' + seconds : seconds; const timeString = hours + ':' + minutes + ':' + seconds; document.getElementById('clock').textContent = timeString; } // Update the clock every second setInterval(updateClock, 1000); updateClock(); // initial call so the clock isn't empty on load // Change the clock's font when the user selects a different font document.getElementById('fontSelector').addEventListener('change', function() { const selectedFont = this.value; document.getElementById('clock').style.fontFamily = selectedFont; }); </script> </body> </html>