html
Copy code
Text Editor
CSS (styles.css)
css
Copy code
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f9;
}
.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.toolbar {
text-align: center;
margin-bottom: 10px;
}
.toolbar button {
background: #007bff;
color: #fff;
border: none;
padding: 10px;
margin: 0 5px;
cursor: pointer;
font-size: 16px;
border-radius: 4px;
}
.toolbar button:hover {
background: #0056b3;
}
#editor {
min-height: 300px;
border: 1px solid #ddd;
padding: 10px;
border-radius: 4px;
background-color: #fafafa;
font-size: 16px;
line-height: 1.5;
}
#editor:focus {
outline: none;
border-color: #007bff;
}
JavaScript (script.js)
javascript
Copy code
function formatText(command) {
document.execCommand(command, false, null);
}
function downloadText() {
const editorContent = document.getElementById('editor').innerHTML;
const blob = new Blob([editorContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'editor-content.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}