The oncut attribute is an event-handler attribute. It runs JavaScript when the cut event fires — the user starts a cut through the browser UI (for example Ctrl+X / Cmd+X, or a Cut menu item).
By default, the selection is copied to the clipboard and removed from the document. Your handler can replace clipboard data with clipboardData.setData(…) and preventDefault() — but canceling also stops the automatic removal, so call selection.deleteFromDocument() if you still want a cut. It cannot read the clipboard. Related: oncopy, onpaste.
Baseline · Widely available.
Not deprecated and not experimental. The cut event is stable across modern browsers since about July 2015. It bubbles, is cancelable, and is composed.
Prefer addEventListener in apps.
Inline oncut is fine for learning. Production code usually uses el.addEventListener("cut", handler). Cutting only works on editable content (inputs, textareas, contenteditable).
Syntax
HTML Syntax
syntax.html
<element oncut="script">
script is JavaScript that runs when cut fires. Equivalent JS: el.oncut = handler or el.addEventListener("cut", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
Select text in the editable box, then cut (Ctrl+X / Cmd+X). Toggle options to transform or block the cut.
On cut
Paste somewhere else to verify uppercase. Block mode leaves the text in place.
Editable text
Select this sample text, then cut it.
Waiting for cut…
Code
HTML Examples
Short, copy-ready snippets. Use Try It Yourself for a live editor.
Example 1 — Inline oncut on a Textarea
Show a status message when the user cuts from the field.
HTML
<label for="notes">Notes:</label>
<textarea id="notes" rows="3" cols="40" oncut="onCutNote()">
Select some text and cut it.
</textarea>
<p id="status">Waiting for cut…</p>
<script>
function onCutNote() {
document.getElementById("status").textContent = "cut event fired.";
}
</script>
User cuts via keyboard or UI — cut fires on the element.
oncut runsonCutNote() and updates status.
Default still cuts — clipboard write + remove — unless you call preventDefault().
Example 2 — Uppercase Cut + Remove Selection
Replace clipboard text and still delete the selection (emulate cut).
HTML
<div id="source" contenteditable="true">
Cut text from this box.
</div>
<p id="hint">Paste elsewhere to see UPPERCASE.</p>
<script>
document.getElementById("source").addEventListener("cut", function (event) {
var selection = document.getSelection();
event.clipboardData.setData(
"text/plain",
selection.toString().toUpperCase()
);
selection.deleteFromDocument();
event.preventDefault();
});
</script>
preventDefault() cancels clipboard write and removal.
Status updates so the student sees the event still ran.
Text stays put — unlike a successful cut.
Edge Cases & Pitfalls
Most mistakes are forgetting that preventDefault also skips removing the selection, or trying to read the clipboard.
vs copy
Cut removes; copy does not
oncopy only writes to the clipboard. oncut writes and deletes the selection by default.
prevent
Canceling skips removal too
If you setData and preventDefault but still want a cut, call selection.deleteFromDocument() yourself.
read
Cannot read clipboard in cut
The handler may write with setData, but it cannot read clipboard contents.
readonly
Uneditable content
cut may still fire on non-editable text, but the event carries no clipboard data and nothing is removed.
synthetic
Synthetic cut events
Dispatching a fake cut does not change the system clipboard or the document. Only a real user-initiated cut does.
Compatibility
Browser Support
oncut is an HTML event-handler attribute for the Clipboard API in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
oncut
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support the cut event on editable content.
97%Global support (approx.)
Google Chrome1+
Full support
Mozilla Firefox22+
Full support
Apple Safari3+
Full support
Microsoft Edge12+
Full support
Opera15+
Full support
Samsung InternetModern · Full
Full support
Internet Explorer9+
Supported
oncutWidely supported
Bottom line: Safe to use for reacting to user cut. Prefer addEventListener in production, and remember preventDefault also blocks removing the selection.
Remember
Key Takeaways
Role: run script when the user initiates a cut.
Default: clipboard write and remove selection.
Customize:setData + preventDefault (+ deleteFromDocument if needed).
Family: pair with oncopy / onpaste as needed.
One line:oncut is copy-plus-remove — cancel carefully if you still need the selection deleted.
Frequently Asked Questions
It is an event-handler attribute. When the user starts a cut action through the browser UI (for example Ctrl+X / Cmd+X), the cut event fires and the JavaScript in oncut runs.
Both can put data on the clipboard. Cut’s default action also removes the selection from the document. Copy leaves the document unchanged.
Yes. Call event.clipboardData.setData("text/plain", yourText) and event.preventDefault(). If you still want the selection removed, call selection.deleteFromDocument() yourself.
No. A cut event handler cannot read clipboard contents. It can only write via clipboardData.setData after canceling the default action.
Both work. For learning, oncut in HTML is fine. In production code, prefer element.addEventListener("cut", handler) so you can attach multiple listeners and keep script out of markup.
No. The cut event and oncut handler are standard and Baseline widely available since about July 2015.