Here's a well-designed HTML page for capturing tasks and reminders with features like adding, editing, deleting, and marking tasks as complete. The tasks are saved to localStorage to persist even after the page is refreshed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Task and Reminder Manager</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f9;
color: #333;
}
header {
background-color: #6200ea;
color: white;
padding: 20px;
text-align: center;
}
.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="text"], input[type="date"], input[type="time"], select, textarea {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
button {
background-color: #6200ea;
color: white;
border: none;
padding: 10px 15px;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #3700b3;
}
.task-list {
margin-top: 20px;
}
.task-item {
background-color: #f9f9f9;
padding: 15px;
margin-bottom: 10px;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
}
.task-actions button {
margin-left: 5px;
background-color: #6200ea;
color: white;
border: none;
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
}
.task-actions button:hover {
background-color: #3700b3;
}
.completed {
text-decoration: line-through;
color: #888;
}
.task-actions i {
margin-right: 5px;
}
</style>
</head>
<body>
<header>
<h1>Task and Reminder Manager</h1>
</header>
<div class="container">
<h2>Add New Task</h2>
<form id="task-form">
<div class="form-group">
<label for="task-title">Title</label>
<input type="text" id="task-title" required>
</div>
<div class="form-group">
<label for="task-description">Description</label>
<textarea id="task-description" rows="3"></textarea>
</div>
<div class="form-group">
<label for="task-due-date">Due Date</label>
<input type="date" id="task-due-date">
</div>
<div class="form-group">
<label for="task-due-time">Due Time</label>
<input type="time" id="task-due-time">
</div>
<div class="form-group">
<label for="task-category">Category</label>
<select id="task-category">
<option value="work">Work</option>
<option value="personal">Personal</option>
<option value="shopping">Shopping</option>
<option value="other">Other</option>
</select>
</div>
<button type="submit">Add Task</button>
</form>
<div class="task-list" id="task-list">
<!-- Tasks will be displayed here -->
</div>
</div>
<script>
document.getElementById('task-form').addEventListener('submit', function(e) {
e.preventDefault();
const title = document.getElementById('task-title').value;
const description = document.getElementById('task-description').value;
const dueDate = document.getElementById('task-due-date').value;
const dueTime = document.getElementById('task-due-time').value;
const category = document.getElementById('task-category').value;
if (title.trim() === '') {
alert('Please enter a title for the task.');
return;
}
const task = {
id: Date.now(),
title,
description,
dueDate,
dueTime,
category,
completed: false
};
addTaskToList(task);
saveTaskToLocalStorage(task);
document.getElementById('task-form').reset();
});
function addTaskToList(task) {
const taskList = document.getElementById('task-list');
const taskItem = document.createElement('div');
taskItem.className = 'task-item';
if (task.completed) {
taskItem.classList.add('completed');
}
taskItem.innerHTML = `
<div>
<h3>${task.title}</h3>
<p>${task.description}</p>
<p>Due: ${task.dueDate} at ${task.dueTime}</p>
<p>Category: ${task.category}</p>
</div>
<div class="task-actions">
<button onclick="toggleComplete(${task.id})"><i class="fas fa-check"></i> Complete</button>
<button onclick="editTask(${task.id})"><i class="fas fa-edit"></i> Edit</button>
<button onclick="deleteTask(${task.id})"><i class="fas fa-trash"></i> Delete</button>
</div>
`;
taskList.appendChild(taskItem);
}
function saveTaskToLocalStorage(task) {
let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
tasks.push(task);
localStorage.setItem('tasks', JSON.stringify(tasks));
}
function loadTasksFromLocalStorage() {
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
tasks.forEach(task => addTaskToList(task));
}
function toggleComplete(id) {
let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
tasks = tasks.map(task => {
if (task.id === id) {
task.completed = !task.completed;
}
return task;
});
localStorage.setItem('tasks', JSON.stringify(tasks));
refreshTaskList();
}
function editTask(id) {
let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
const task = tasks.find(task => task.id === id);
if (task) {
document.getElementById('task-title').value = task.title;
document.getElementById('task-description').value = task.description;
document.getElementById('task-due-date').value = task.dueDate;
document.getElementById('task-due-time').value = task.dueTime;
document.getElementById('task-category').value = task.category;
// Remove the task from the list
tasks = tasks.filter(task => task.id !== id);
localStorage.setItem('tasks', JSON.stringify(tasks));
refreshTaskList();
}
}
function deleteTask(id) {
let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
tasks = tasks.filter(task => task.id !== id);
localStorage.setItem('tasks', JSON.stringify(tasks));
refreshTaskList();
}
function refreshTaskList() {
const taskList = document.getElementById('task-list');
taskList.innerHTML = '';
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
tasks.forEach(task => addTaskToList(task));
}
// Load tasks when the page loads
window.onload = loadTasksFromLocalStorage;
</script>
</body>
</html>
This HTML page includes a form to add new tasks with fields for title, description, due date, due time, and category. It also displays the list of tasks with options to mark them as complete, edit, or delete. The tasks are saved to localStorage so they persist even after the page is refreshed. The design is clean and modern, with a responsive layout that works well on different screen sizes. Icons are used for actions like edit, delete, and complete to enhance the user experience.