<!DOCTYPE html>
<html>
<head>
<title>Simple To-Do List</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
padding: 50px;
background-color: #f9f9f9;
}
.todo-container {
background-color: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
width: 400px;
text-align: center;
}
input {
width: 70%;
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
padding: 10px 15px;
font-size: 16px;
border: none;
background-color: #28a745;
color: white;
border-radius: 5px;
cursor: pointer;
}
ul {
list-style-type: none;
padding: 0;
margin-top: 20px;
}
li {
background-color: #f1f1f1;
margin: 8px 0;
padding: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="todo-container">
<h1>To-Do List</h1>
<input type="text" id="taskInput" placeholder="Enter a task">
<button onclick="addTask()">Add Task</button>
<ul id="taskList"></ul>
</div>
<script>
function addTask() {
let task = document.getElementById("taskInput").value;
let li = document.createElement("li");
li.textContent = task;
document.getElementById("taskList").appendChild(li);
document.getElementById("taskInput").value = "";
}
</script>
</body>
</html>
previous post
