Below is an example of a simple, beautiful notes webapp built using HTML, CSS, and JavaScript. This app lets you add and delete notes—with your notes persisting in the browser's local storage so they remain even after refreshing the page.
You can create three files: index.html, style.css, and app.js. Follow these steps:
1. Create index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Beautiful Notes App</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>My Notes</h1>
<form id="note-form">
<textarea id="noteInput" placeholder="Write your note here..." required></textarea>
<button type="submit">Add Note</button>
</form>
<div id="notes"></div>
</div>
<script src="app.js"></script>
</body>
</html>
2. Create style.css
/* Basic reset */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* Body styling */
body {
font-family: 'Arial', sans-serif;
background: #f4f7f6;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
/* Container styling */
.container {
background: #fff;
width: 400px;
max-width: 90%;
border-radius: 8px;
padding: 20px 25px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
/* Heading style */
h1 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
/* Form styling */
#note-form {
margin-bottom: 20px;
display: flex;
flex-direction: column;
}
#noteInput {
min-height: 100px;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
font-size: 16px;
resize: vertical;
margin-bottom: 10px;
}
/* Button styling */
button {
background: #3498db;
color: #fff;
border: none;
padding: 10px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background 0.3s ease;
}
button:hover {
background: #2980b9;
}
/* Notes display styling */
#notes {
display: flex;
flex-direction: column;
gap: 10px;
}
.note {
background: #ecf0f1;
padding: 12px;
border-radius: 5px;
position: relative;
word-wrap: break-word;
}
/* Delete button styling inside each note */
.delete-btn {
background: transparent;
border: none;
color: #e74c3c;
cursor: pointer;
font-size: 14px;
position: absolute;
top: 10px;
right: 10px;
}
3. Create app.js
document.addEventListener("DOMContentLoaded", function () {
const noteForm = document.getElementById("note-form");
const noteInput = document.getElementById("noteInput");
const notesContainer = document.getElementById("notes");
// Load notes from localStorage when the page loads
function loadNotes() {
const notes = JSON.parse(localStorage.getItem("notes")) || [];
notesContainer.innerHTML = "";
notes.forEach((note, index) => {
addNoteToDOM(note, index);
});
}
// Create note element in the DOM
function addNoteToDOM(text, index) {
const noteDiv = document.createElement("div");
noteDiv.classList.add("note");
noteDiv.innerHTML = `
<span>${text}</span>
<button class="delete-btn" onclick="deleteNote(${index})">Delete</button>
`;
notesContainer.appendChild(noteDiv);
}
// Save a new note and update localStorage
function saveNote(note) {
const notes = JSON.parse(localStorage.getItem("notes")) || [];
notes.push(note);
localStorage.setItem("notes", JSON.stringify(notes));
loadNotes();
}
// Listen for form submission
noteForm.addEventListener("submit", function (e) {
e.preventDefault();
const text = noteInput.value.trim();
if (text !== "") {
saveNote(text);
noteInput.value = "";
}
});
// Delete a note by its index
window.deleteNote = function (index) {
const notes = JSON.parse(localStorage.getItem("notes")) || [];
notes.splice(index, 1);
localStorage.setItem("notes", JSON.stringify(notes));
loadNotes();
};
// Initial load
loadNotes();
});
How It Works
-
HTML Structure:
- The form allows users to type a note and submit it.
- A container below the form displays all notes.
-
CSS Styling:
- A clean and modern design is applied with a centered container, soft shadows, and rounded corners.
- Styling is included for buttons, textarea, and note cards to give a cohesive look.
-
JavaScript Functionality:
- The app listens for the page to load and then initializes by pulling any existing notes from
localStorage.
- When a note is submitted, it is saved to
localStorage and displayed.
- The delete function removes the note from both the DOM and
localStorage.
Simply place these files in the same directory and open index.html in your web browser to start using your beautiful notes webapp. Enjoy making and managing your notes!