Open In App
Related Articles

HTML onpaste Event Attribute

Improve Article
Save Article
Like Article

The onpaste attribute works when some content are paste in an element. This event attribute is supported by all HTML elements. It is mostly used with <input> element.
There are three ways to paste the content in HTML elements which are listed below: 

  • Use CTRL + V key
  • Select “Paste” from the edit menu in the browser.
  • select the “Paste” command from right-click menu

Supported Tags: It supports all HTML elements. 


<element onpaste = "script">

Attribute Value: The script event run when onpaste attribute is called.


<!DOCTYPE html>
    <title>onpaste attribute</title>
        body {
            text-align: center;
        h1 {
            color: green;
    <h2>onpaste Attribute</h2>
    <input type="text"
           value="A computer science portal for geeks"
    <p id="sudo"></p>
        function Geeks() {
            document.getElementById("sudo").innerHTML = "pasted text!";


Supported Browsers: The browser supported by onpaste attribute are listed below: 

  • Apple Safari 3
  • Google Chrome 1
  • Edge 12
  • Firefox 22
  • Opera 12.1

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 04 Aug, 2023
Like Article
Save Article
Similar Reads
Complete Tutorials