Placeholder breaks first character of Hangul composition
OS: Android 14.0 · Device: Smartphone Any · Browser: Chrome 131.0
Open case →Scenario
Technical analysis of how CSS and attribute-based placeholders disrupt text insertion and IME sessions.
Standard <input> and <textarea> elements have native placeholder support. contenteditable does not. Developers typically simulate placeholders using the CSS :empty:before selector or by injecting a pseudo-node. This simulation often creates a “Race Condition” where the browser’s logic for removing the placeholder collides with the user’s logic for inserting text, particularly during the startup of an IME session.
In Chrome 131+ on Android, when the first character of a Korean syllable is typed, the DOM mutation triggered by CSS removing the :before placeholder (because the element is no longer :empty) causes the browser to reset its internal IME buffer.
/* Chrome Logic Loop */
// 1. User types 'ㅎ'
// 2. Element is no longer :empty
// 3. CSS pseudo-element is destroyed
// 4. Mutation event clears the text node 'ㅎ' incorrectly
In Safari, the placeholder often remains visible until a character is typed, but if the placeholder has different padding/font than the text, focusing it can cause a “jump” that moves the caret unexpectedly.
:empty transitions safely but may fail to render a caret in zero-height divs.Instead of allowing :empty to destroy the node, toggle its visibility or opacity based on a manually maintained is-empty class or the focus state.
/* Avoid content: "" changes mid-type */
[contenteditable]::before {
content: attr(placeholder);
opacity: 0.5;
}
[contenteditable]:not(:empty)::before,
[contenteditable]:focus::before {
display: none; /* or visibility: hidden */
}
Explicitly remove the placeholder state when the element is focused, before any composition events fire.
Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.
Each row is a concrete case for this scenario, with a dedicated document and playground.
| Case | OS | Device | Browser | Keyboard | Status |
|---|---|---|---|---|---|
| ce-0056-contenteditable-with-placeholder | macOS Ubuntu 22.04 | Desktop or Laptop Any | Safari 120.0 | US | draft |
| ce-0568-chrome-android-placeholder-korean-ime | Android 14.0 | Smartphone Any | Chrome 131.0 | Korean (IME) | confirmed |
This matrix shows which browser and OS combinations have documented cases for this scenario. Click on a cell to view the specific case.
| Browser | Android | macOS |
|---|---|---|
| Chrome | — | |
| Safari | — |
This scenario affects multiple languages. Cases are grouped by language/input method below.
OS: Android 14.0 · Device: Smartphone Any · Browser: Chrome 131.0
Open case →OS: macOS Ubuntu 22.04 · Device: Desktop or Laptop Any · Browser: Safari 120.0
Open case →Other scenarios that share similar tags or category.
Managing browser UI collisions, virtual keyboard resizing, and IME candidate window positioning.
During IME composition or in certain browser/IME combinations, the beforeinput event may have a different inputType than the corresponding input event. For example, beforeinput may fire with insertCompositionText while input fires with deleteContentBackward. This mismatch can cause handlers to misinterpret the actual DOM change and requires storing beforeinput's targetRanges for use in input event handling.
The selection (window.getSelection()) in beforeinput events can differ from the selection in corresponding input events. This mismatch can occur during IME composition, text prediction, or when typing adjacent to formatted elements like links. The selection in beforeinput may include adjacent formatted text, while input selection reflects the final cursor position.
When browser translation features (like Google Translate) are activated, they manipulate the DOM by replacing text content and injecting elements. This can break contenteditable functionality, causing cursor positioning issues, event handling problems, and IME composition failures.
Analysis of how out-of-order or missing composition events disrupt editor state synchronization.
Have questions, suggestions, or want to share your experience? Join the discussion below.