<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Color Generator</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f2f5;
}
.container {
text-align: center;
}
.color-box {
width: 200px;
height: 200px;
margin: 20px auto;
background-color: #ffffff;
border: 1px solid #ddd;
border-radius: 8px;
}
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: white;
font-size: 1em;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Random Color Generator</h1>
<div class="color-box" id="colorBox"></div>
<button onclick="generateColor()">Generate Color</button>
</div>
<script>
function generateColor() {
const colorBox = document.getElementById('colorBox');
const randomColor = '#' + Math.floor(Math.random()*16777215).toString(16);
colorBox.style.backgroundColor = randomColor;
}
</script>
</body>
</html>