How to Create Text Editor using HTML CSS and JavaScript? Last Updated : 08 Nov, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The style property in JavaScript is used to create a text editor with HTML and CSS. This editor features buttons for text formatting, including options for bold, italic, left, center, and right alignment, as well as uppercase, lowercase, and capitalized transformations. Each button triggers a function that updates the textarea content based on the selected style, providing an interactive way to format text directly within the editor.Creating a Text Editor using HTML, CSS, and JavaScriptCreate a structure using <textarea> for text input and buttons for formatting actions (like bold, italic, etc.).Style the text editor and buttons to make it visually appealing with colors, borders, and spacing.Add buttons that, when clicked, trigger specific JavaScript functions to apply formatting like bold, italics, text alignment, or case transformation.Each function manipulates the text inside the <textarea> by changing its style (e.g. fontWeight for bold, textAlign for alignment).The user can clear or change the text's appearance instantly by interacting with these buttons.Example: Building a basic text editor with HTML, CSS, and JavaScript. HTML <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Text Editor</title> <link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css"> </head> <body> <section> <h1>TEXT EDITOR</h1> <div class="button-container"> <button onclick="editoroption1()" title="Bold Text"> Bold </button> <button onclick="editoroption2()" title="Italic Text"> Italic </button> <button onclick="editoroption3()" title="Left Align"> <i class="fas fa-align-left"></i> </button> <button onclick="editoroption4()" title="Center Align"> <i class="fas fa-align-center"></i> </button> <button onclick="editoroption5()" title="Right Align"> <i class="fas fa-align-right"></i> </button> <button onclick="editoroption6()" title="Uppercase Text"> Upper Case </button> <button onclick="editoroption7()" title="Lowercase Text"> Lower Case </button> <button onclick="editoroption8()" title="Capitalize Text"> Capitalize </button> <button onclick="editoroption9()" title="Clear Text"> Clear Text </button> </div> <textarea id="textarea1" rows="15" placeholder="Your text here..."> </textarea> </section> <script src="script.js"></script> </body> </html> CSS /* styles.css */ body { font-family: 'Arial', sans-serif; background-color: #f3f4f6; color: #333; margin: 0; padding: 20px; } h1 { text-align: center; color: #4A4A4A; } .section { padding: 20px; border-radius: 8px; background-color: #fff; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); } .button-container { display: flex; justify-content: center; margin-bottom: 20px; } button { margin: 5px; padding: 10px 15px; border: none; border-radius: 5px; background-color: #4CAF50; color: white; cursor: pointer; transition: background-color 0.3s; } button:hover { background-color: #45a049; } textarea { width: 100%; border: 1px solid #4CAF50; border-radius: 5px; padding: 10px; resize: none; font-size: 16px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } JavaScript //script.js function editoroption1() { document.getElementById("textarea1") .style.fontWeight = "bold"; } function editoroption2() { document.getElementById("textarea1") .style.fontStyle = "italic"; } function editoroptionr3() { document.getElementById("textarea1") .style.textAlign = "left"; } function editoroption4() { document.getElementById("textarea1") .style.textAlign = "center"; } function editoroption5() { document.getElementById("textarea1") .style.textAlign = "right"; } function editoroption6() { document.getElementById("textarea1") .style.textTransform = "uppercase"; } function editoroption7() { document.getElementById("textarea1") .style.textTransform = "lowercase"; } function editoroption8() { document.getElementById("textarea1") .style.textTransform = "capitalize"; } function editoroption9() { document.getElementById("textarea1") .style.fontWeight = "normal"; document.getElementById("textarea1") .style.textAlign = "left"; document.getElementById("textarea1") .style.fontStyle = "normal"; document.getElementById("textarea1") .style.textTransform = "capitalize"; document.getElementById("textarea1") .value = ""; } Output Comment More infoAdvertise with us P priyanshjha99 Follow Improve Article Tags : JavaScript HTML5 HTML-DOM HTML-Questions JavaScript-Questions +1 More Similar Reads JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read Introduction to JavaScript JavaScript is a versatile, dynamically typed programming language used for interactive web applications, supporting both client-side and server-side development, and integrating seamlessly with HTML, CSS, and a rich standard library.JavaScript is a single-threaded language that executes one task at 7 min read JSON Web Token (JWT) A JSON Web Token (JWT) is a standard used to securely transmit information between a client (like a frontend application) and a server (the backend). It is commonly used to verify users' identities, authenticate them, and ensure safe communication between the two. JWTs are mainly used in web apps an 7 min read Frontend Developer Interview Questions and Answers Frontend development is an important part of web applications, and it is used to build dynamic and user-friendly web applications with an interactive user interface (UI). Many companies are hiring skilled Frontend developers with expertise in HTML, CSS, JavaScript, and modern frameworks and librarie 15+ min read JavaScript Coding Questions and Answers JavaScript is the most commonly used interpreted, and scripted Programming language. It is used to make web pages, mobile applications, web servers, and other platforms. Developed in 1995 by Brendan Eich. Developers should have a solid command over this because many job roles need proficiency in Jav 15+ min read Top 95+ Javascript Projects For 2025 JavaScript is a lightweight, cross-platform programming language that powers dynamic and interactive web content. From real-time updates to interactive maps and animations, JavaScript brings web pages to life.Here, we provided 95+ JavaScript projects with source code and ideas to provide hands-on ex 4 min read Functions in JavaScript Functions in JavaScript are reusable blocks of code designed to perform specific tasks. They allow you to organize, reuse, and modularize code. It can take inputs, perform actions, and return outputs.JavaScriptfunction sum(x, y) { return x + y; } console.log(sum(6, 9)); // output: 15Function Syntax 5 min read HTML Forms HTML forms, defined using the <form> Tags are essential for collecting user input on web pages. They incorporate a variety of interactive controls such as text fields, numeric inputs, email fields, password fields, checkboxes, radio buttons, and submit buttons. Over 85% of websites rely on for 5 min read Like