Convert your Browser into a Notepad with HTML5 contenteditable Attribute

← PrevNext →

Last updated: 07th July 2025

Did you know your web browser can double as a notepad? With modern HTML5 capabilities, you can quickly transform any browser into a minimalist writing environment, no extensions needed. This powerful yet simple trick is gaining attention among bloggers and digital writers as a lightweight alternative for drafting content, taking notes, or even journaling on the go.

👉 Check this out!

Turning Your Browser into a Notepad Is Easier Than You Think

You don’t need complex tools or apps, just your web browser and a quick trick using HTML5. Follow these simple steps to create a lightweight, editable notepad right inside your browser:

1) Launch any modern web browser like Google Chrome, Firefox, or Microsoft Edge.
2) Copy the following string and paste it directly into your browser’s address bar, and press the Enter key.

data:text/html, <html contenteditable>

3) You'll see a blank editable page. Click on it and start typing, voila, your browser is now a minimalist notepad.

📱 Mobile-Friendly Too: This feature isn’t limited to desktops, it works seamlessly on most mobile browsers as well.

💾 Save Your Notes: Want to preserve your work? You can save anything you’ve typed directly on the page as an HTML file. Simply press Ctrl + S (or Cmd + S on Mac), then choose a destination on your device to store the file for later access.

See this demo
How does it works?

This trick leverages the Data URI scheme, which instructs the browser to generate a new HTML page directly from a string of code, without needing a server. By combining it with the contenteditable attribute, the browser renders a page that behaves like a simple notepad where users can type freely.

Why don't you just try this. Copy the below code and paste it in your browser’s address bar. Press the Enter key.

data:text/html, 'Hello World'

🚀 You've Just Created Your First HTML Page! Even if you're not a developer or web designer, this simple trick lets you craft your very first HTML page—right from your browser. When you paste the code, it displays a classic Hello, World message directly on the page.

💡 Making Pages Editable with HTML5: This works by using the powerful contenteditable attribute in HTML5. It’s a built-in feature that allows any supported HTML element like a <div> or <p>, to become editable right inside the browser. By enabling this attribute, users can interact with the content, type freely, and even experiment with page editing in real time.

Experiment with Other HTML Elements

The fun doesn’t stop with just <html>, you can try this trick with various HTML elements. One of the most versatile is the <div> tag, commonly used to group and structure content on a webpage.

In the next example, we’ll transform a simple <div> into an editable notepad by applying the contenteditable attribute along with some inline CSS. This gives the container a defined width, height, and a visible border, making it look and feel like a basic text editor.

Copy the line below and paste it into your browser's address bar. Then hit Enter.

data:text/html, <div contenteditable style="width:500px; height:500px; border:3px dashed gray;">

👍 Nice work! Not only have you made the <div> editable, but you’ve also defined its width and height, transforming it into a functional text box. Plus, the border helps visually mark the area—making it clear where to start typing.

🚀 In-addition, you add scrollbars to your editor.

To add scrollbars to your editable <div> notepad, all we need to do is apply a overflow:auto; style. This tells the browser to show scrollbars only when necessary, which keeps your layout tidy while still allowing users to navigate larger content.

data:text/html,<div contenteditable style="width:500px; height:300px; border:3px dashed gray; padding:10px; overflow:auto;">Start typing here...</div>

Save Your Notes as a Text File

Taking It a Step Further

This example has practical value and can serve as a solid foundation for building a lightweight browser-based editor. As mentioned earlier, you can easily "save the contents" of the in-browser notepad in HTML format (see the link above for details). Additionally, you can export the content as a .txt file using JavaScript and jQuery.

To accomplish this, we’ll use the traditional BLOB (Binary Large Object) approach, which enables the browser to generate a file and prompt the user to save it locally. This method is efficient and widely supported—perfect for client-side text handling without relying on a server.

In this example, we’ll transform a simple DIV element into an editable area using the contenteditable attribute. By placing a button at the top of the browser page, we enable users to conveniently save their notes or content to their local disk.

The contenteditable attribute is a Boolean type HTML5 feature that defines whether the element’s content can be edited by the user. It supports the following three values:

01) contenteditable = "true"

Setting it to "true" will make it editable.
e.g.: <div contenteditable></div> or <div contenteditable></div>

02) contenteditable = "false"

Don’t want to allow any changes to elements contents, set it as false.
e.g.: <div contenteditable="false"></div>

03) contenteditable = "inherit"

True or false depends of the value of its immediate parent element.

The Example:

<!DOCTYPE html>
<html>
<head>
    <title>HTML5 "contenteditable"</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

    <style>
        body { 
            font:normal normal 16px/1.4 arial;
        }
        :focus {outline:0;}
        div {
            width:100%;
            height:90%;
            color:#333;
            margin:20px 0;
        }
        ul {
            list-style:none;
            padding:0;
            margin:0;
            display:inline-block;
        }
        ul li {
            float:left;
            padding:0 10px;
            cursor:pointer;
        }
    </style>
</head>
<body>
    <ul>
        <li><input type="button" id="btSave" value="Save Text to File" /></li>
    </ul>
    <div contenteditable></div>
</body>

<script>
    $(document).ready(function() {
        $('div').focus();

        $('#btSave').click(function() {

            if ($('div').text() != '')
                saveFile($('div').text());
            else
                alert('No notes to save');
        });
    });

    // USING BLOB (BINARY LARGE OBJECT) TO SAVE THE TEXT.

    function saveFile(Value) {

        // CONVERT THE TEXT TO A BLOB.
        var textToBLOB = new Blob([Value], { type: 'text/plain' });
        var sFileName = 'myFile.txt';       // THE FILE IN WHICH THE CONTENTS WILL BE SAVED.

        var newLink = document.createElement("a");
        newLink.download = sFileName;

        if (window.webkitURL != null) {
            newLink.href = window.webkitURL.createObjectURL(textToBLOB);
        }
        else {
            newLink.href = window.URL.createObjectURL(textToBLOB);
            newLink.style.display = "none";
            document.body.appendChild(newLink);
        }

        newLink.click();
    }
</script>
</html>
See this demo

📌 Important Note on Editable Elements

Keep in mind that when an element has contenteditable="true", all of its child elements inherit this behavior by default, making them editable as well.

<div contenteditable>
    Text inside DIV is editable.
    
    <p style="border:solid 1px"> Inside paragraph </p>
</div>

However, if you want certain child elements to remain non-editable, such as a button, label, or paragraph, you'll need to explicitly set contenteditable="false" on those elements. This ensures that while the parent remains an editable area, the designated children are protected from user modifications.

<p style="border:solid 1px" contenteditable="false">Inside paragraph</p>
Conclusion

While the browser’s address bar isn’t traditionally intended for injecting HTML, CSS, or JavaScript, a small snippet, like the one demonstrated earlier, can cleverly repurpose it into a basic in-browser editor. Of course, building a full-fledged editor requires additional functionality beyond the foundational HTML5 attributes.

That said, even this minimal setup offers a distinct advantage: it enables users to leave feedback, share their thoughts, or report bugs directly within a webpage. This capability mirrors a core feature found in most Content Management System (CMS) platforms, which allow users to edit site content dynamically. It’s a simple yet powerful step toward creating interactive, editable web experiences.

👉 Check this out!

Next →