We build the app
Section 4: The project: the to-do listLesson 4.2 · ⏱ 12 min
HTML
<input id="task" placeholder="New task">
<button id="add">add</button>
<ul id="list"></ul>
CSS
body { font-family: Tahoma; padding: 20px; }
input, button { font-size: 20px; padding: 6px 12px; }
li { font-size: 20px; margin: 6px 0; }
JavaScript
const input = document.getElementById("task");
document.getElementById("add").onclick = function () {
if (input.value.trim() === "") return;
const li = document.createElement("li");
li.textContent = input.value;
document.getElementById("list").appendChild(li);
input.value = "";
};
🖥️ The page in Robo Web:

📌 Another example: the shopping list with a count
We add the things, and write how many there are under the list.
HTML
<input id="task" placeholder="What shall we buy?">
<button id="add">Add</button>
<ul id="list"></ul>
<p id="n">0 things</p>
CSS
body { font-family: Tahoma, sans-serif; }
input, button { font-size: 20px; padding: 6px 12px; }
li { font-size: 20px; margin: 6px 0; }
JavaScript
const input = document.getElementById("task");
let count = 0;
document.getElementById("add").onclick = function () {
if (input.value.trim() === "") return;
const li = document.createElement("li");
li.textContent = "🛒 " + input.value;
document.getElementById("list").appendChild(li);
input.value = "";
count++;
document.getElementById("n").textContent = count + " things";
};
🖥️ The page in Robo Web:

✍️ Practise
The to-do list.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
Every task starts with ✅.
👀 Show the solution🙈 Hide the solution
HTML
<input id="task" placeholder="New task">
<button id="add">Add</button>
<ul id="list"></ul>
CSS
body { font-family: Tahoma, sans-serif; }
input, button { font-size: 20px; padding: 6px 12px; }
li { font-size: 20px; margin: 6px 0; }
JavaScript
document.getElementById("add").onclick = function () {
const li = document.createElement("li");
li.textContent = "✅ " + document.getElementById("task").value;
document.getElementById("list").appendChild(li);
};
🖥️ The page in Robo Web:

Result: ✅ Study
Medium
Clicking a task crosses it out (line-through).
👀 Show the solution🙈 Hide the solution
HTML
<input id="task" placeholder="New task">
<button id="add">Add</button>
<ul id="list"></ul>
CSS
body { font-family: Tahoma, sans-serif; }
input, button { font-size: 20px; padding: 6px 12px; }
li { font-size: 20px; margin: 6px 0; }
JavaScript
document.getElementById("add").onclick = function () {
const li = document.createElement("li");
li.textContent = document.getElementById("task").value;
li.onclick = function () {
li.style.textDecoration = "line-through";
};
document.getElementById("list").appendChild(li);
};
🖥️ The page in Robo Web:

Result: the task is crossed out.
Hard
A 🗑 button next to every task deletes it.
👀 Show the solution🙈 Hide the solution
HTML
<input id="task" placeholder="New task">
<button id="add">Add</button>
<ul id="list"></ul>
CSS
body { font-family: Tahoma, sans-serif; }
input, button { font-size: 20px; padding: 6px 12px; }
li { font-size: 20px; margin: 6px 0; }
JavaScript
document.getElementById("add").onclick = function () {
const li = document.createElement("li");
li.textContent = document.getElementById("task").value + " ";
const del = document.createElement("button");
del.textContent = "🗑";
del.onclick = function () { li.remove(); };
li.appendChild(del);
document.getElementById("list").appendChild(li);
};
🖥️ The page in Robo Web:

Result: one task is left.

