Build a To-Do App using HTML, CSS & JavaScript ⚡
⚡ Build a To-Do App using HTML, CSS & JavaScript
Hello everyone π
Welcome back!
In this beginner-friendly project, we will create a simple To-Do App using HTML, CSS, and JavaScript π»
This project helps you learn:
- DOM Manipulation
- Event Handling
- LocalStorage
- JavaScript Logic
Perfect for beginners π
---
π Features of To-Do App
✔ Add new tasks
✔ Mark tasks as completed
✔ Delete tasks
✔ Clean responsive design
✔ Data stored using LocalStorage
---
π§± Step 1: HTML Code
<!DOCTYPE html>
<html>
<head>
<title>To-Do App</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="todo-container">
<h1>My To-Do List</h1>
<div class="input-section">
<input type="text" id="taskInput" placeholder="Enter your task...">
<button id="addBtn">Add</button>
</div>
<ul id="taskList"></ul>
</div>
<script src="script.js"></script>
</body>
</html>
---
π¨ Step 2: CSS Code
body {
font-family: Arial;
background: #f4f6f8;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.todo-container {
background: white;
padding: 25px;
width: 400px;
border-radius: 10px;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.input-section {
display: flex;
gap: 10px;
}
input {
flex: 1;
padding: 10px;
}
button {
padding: 10px 15px;
background: green;
color: white;
border: none;
cursor: pointer;
}
li {
margin-top: 10px;
}
---
⚡ Step 3: JavaScript Code
let taskInput = document.getElementById("taskInput");
let addBtn = document.getElementById("addBtn");
let taskList = document.getElementById("taskList");
addBtn.addEventListener("click", addTask);
function addTask() {
let task = taskInput.value;
if(task === "") {
alert("Please enter a task");
return;
}
let li = document.createElement("li");
li.textContent = task;
li.addEventListener("click", function() {
li.style.textDecoration = "line-through";
});
let deleteBtn = document.createElement("button");
deleteBtn.textContent = "Delete";
deleteBtn.addEventListener("click", function() {
li.remove();
});
li.appendChild(deleteBtn);
taskList.appendChild(li);
taskInput.value = "";
}
---
π― What You Will Learn
✅ DOM Manipulation
✅ JavaScript Events
✅ Dynamic Task Creation
✅ Beginner Project Logic
---
⭐ Tips
- Try changing colors π¨
- Add dark mode π
- Store tasks in LocalStorage πΎ
---
π Conclusion
This was a simple To-Do App project using JavaScript.
A perfect beginner project to improve your coding skills π
---
π’ Also Read
- JavaScript Interview Guide
- Calculator Project
- Python Programs
---
π Save and share this post π
π Follow for more coding projects π»
Comments
Post a Comment