Placeholder support for contentEditable elements, without JavaScript
How do I make an placeholder support for contenteditable elements, without javascript?
What is a placeholder support for contenteditable elements, without javascript? How do you make a placeholder support for contenteditable elements, without javascript? This script and codes were developed by Ariel Flesler on 28 July 2022, Thursday.
Placeholder support for contentEditable elements, without JavaScript - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Placeholder support for contentEditable elements, without JavaScript</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Placeholder support for contentEditable elements, without JavaScript</h1>
<div contenteditable="true" placeholder="Enter text here..."></div>
<p>All you need is to add the following CSS:</p>
<pre>
[contenteditable=true]:empty:before { content: attr(placeholder); display: block; /* For Firefox */
}
</pre>
<h2>Notes</h2>
<ul> <li>Can add a different style than actual text like opacity, italic, etc</li> <li>If your html needs to be 100% compliant, you can replace "placeholder" for "data-placeholder" on both files</li> <li>Chrome will add <br />'s inside contentEditable elements in some cases, breaking the :empty check. Can be fixed with a bit of JavaScript.</li>
</ul>
<i>By Ariel Flesler</i>
</body>
</html>
Placeholder support for contentEditable elements, without JavaScript - Script Codes CSS Codes
[contenteditable=true]:empty:before{ content: attr(placeholder); display: block; /* For Firefox */
}
/* */
div[contenteditable=true] { border: 1px dashed #AAA; width: 290px; padding: 5px;
}
pre { background:#EEE; padding:5px; width: 290px;
}
Developer | Ariel Flesler |
Username | flesler |
Uploaded | July 28, 2022 |
Rating | 4.5 |
Size | 1,863 Kb |
Views | 91,080 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
YouTube Embed | 1,302 Kb |
JQuery Detection | 2,576 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Polygon Logo in CSS | Kai | 3,412 Kb |
Barber Shop | Bhlaird | 6,270 Kb |
We Simplify animation | Meodai | 48,169 Kb |
SnappySnippet Test | Elmsoftware | 8,385 Kb |
Flexbox Grid - equal height | DaveOrDead | 2,855 Kb |
SCSS Unit Conversion | Jakob-e | 8,210 Kb |
Gradients | Karpovsystems | 2,394 Kb |
Improved Page Flipping Effect | Usaphp | 5,201 Kb |
Portfolio page | Bhavya_j | 2,804 Kb |
Box Shadow Effects | Retrofuturistic | 2,143 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!