Thursday, September 4, 2025
HomeLanguagesJavascriptHow to add Summernote Editor in webpage ?

How to add Summernote Editor in webpage ?

In this article, we will know about the Summernote Editor & its usage along with will understand its implementation through the example. The Summernote EditorĀ is a free & open-source super simple WYSIWYG editor based on Bootstrap & jQuery. It is a JavaScript library that can be useful to build the WYSIWYG editors online. It is maintained under MIT license by a large community. It is easy to use & contains many customizable options. It can easily be implemented in any framework like React, Django, Angular, etc.

Ā 

Features:

  • Lightweight Rich Text Editor
  • Easy installation
  • Easy integration with any framework
  • Simple UI
  • Lots of customization available.
  • Free & Open-source
  • Interactive WYSIWYG editing

There are 2 ways to use the Summernote Editor on our web page:

  • Using the downloaded precompiled and minified versions of CSS and JavaScript files from their official site.
  • Using the available CDN links for summernote CSS & js, jQuery, and Bootstrap.

We can use either of the methods to build the static site with the text editor and the content.

Approach:

  • First, download the minified precompiled version of Summernote from the official website.
  • Extract it & place it in the current working folder.
  • Create an index.html file & declare the Bootstrap & jQuery links inside the <head> tag.
  • After completing these steps, the project structure will look like the following image.

Import the Summernote:

  • First, let us import the Bootstrap from CDNs in the index.html file. All the following codes should be placed inside the Head Tags.

<!– Include libraries(jQuery, bootstrap) –>
<link href=ā€https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.cssā€ rel=ā€stylesheetā€/>
<script src=ā€https://code.jquery.com/jquery-3.5.1.min.jsā€></script>
<script src=ā€https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.jsā€></script>

  • Next import the summernote CSS and JS files.

<link href=ā€/src/summernote-0.8.18-dist/summernote-bs4.min.cssā€ rel=ā€stylesheetā€/>
<script src=ā€/src/summernote-0.8.18-dist/summernote-bs4.min.jsā€></script>

  • Now in the <body> tag, initialize the summernote editor.

<div id=ā€myeditorā€></div>

<script>
$(document).ready(function() {
    $("#myeditor").summernote({
        placeholder: "Write your content here",
        height: 200,
    });
});
</script>

Now, our Text Editor has been initialized.

Example: This example illustrates the use of the Summernote Editor to build & facilitate the editor in the web pages.

HTML




<!DOCTYPE html>
<html lang="en">
Ā Ā 
<head>
Ā Ā Ā Ā <meta charset="UTF-8" />
Ā Ā Ā Ā <meta http-equiv="X-UA-Compatible" content="IE=edge" />
Ā Ā Ā Ā <meta name="viewport"Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā content="width=device-width, initial-scale=1.0" />
Ā Ā Ā Ā <title>neveropen Editor</title>
Ā Ā Ā Ā <link href=
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā rel="stylesheet" />
Ā Ā Ā Ā <script src=
Ā Ā Ā Ā </script>
Ā Ā Ā Ā <script src=
Ā Ā Ā Ā </script>
Ā Ā Ā Ā <link rel="stylesheet"Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā href="/src/summernote-0.8.18-dist/summernote-bs4.min.css" />
Ā Ā Ā Ā <script src="/src/summernote-0.8.18-dist/summernote-bs4.min.js"></script>
Ā Ā Ā Ā <link rel="stylesheet"Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā href="/src/summernote-0.8.18-dist/summernote.css" />
Ā Ā Ā Ā <script src="/src/summernote-0.8.18-dist/summernote.js"></script>
</head>
Ā Ā 
<body>
Ā Ā Ā Ā <h1>neveropen Editor</h1>
Ā Ā Ā Ā <div id="myeditor"></div>
Ā Ā Ā Ā <button type="button"Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā class="btn btn-success"Ā 
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā onclick="showContent()"> ShowĀ 
Ā Ā Ā Ā </button>
Ā Ā 
Ā Ā Ā Ā <div id="myContent" class="container"></div>
Ā Ā 
Ā Ā Ā Ā <script>
Ā Ā Ā Ā $(document).ready(function() {
Ā Ā Ā Ā Ā Ā Ā Ā $("#myeditor").summernote({
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā placeholder: "Write your content here",
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā height: 200,
Ā Ā Ā Ā Ā Ā Ā Ā });
Ā Ā Ā Ā });
Ā Ā 
Ā Ā Ā Ā function showContent() {
Ā Ā Ā Ā Ā Ā Ā Ā document.getElementById("myContent").innerHTML =Ā 
Ā Ā Ā Ā Ā Ā Ā Ā $("#myeditor").summernote("code");
Ā Ā Ā Ā }
Ā Ā Ā Ā </script>
</body>
Ā Ā 
</html>


Output:

Supported Browsers:

  • Google Chrome
  • Firefox
  • Microsoft Edge
  • Internet Explorer
  • Opera
  • Safari

Reference: https://summernote.org/

RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6629 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11858 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6716 POSTS0 COMMENTS