Copy the Zero Width Space character:
What Is Zero Width Space?
Zero Width Space (U+200B) is a Unicode character that occupies no visual space. Unlike a regular space or even a non-breaking space, it renders as absolutely nothing on screen. The character is invisible, yet it exists in the text stream and can affect how browsers handle line breaks, word boundaries, and text selection.
The Zero Width Space was introduced in Unicode 1.0.0 back in 1991 as part of the initial set of characters designed for international text encoding. It belongs to the General Punctuation block (U+2000–U+206F), which houses various formatting and invisible characters. The character was originally conceived for use in languages like Thai, Khmer, and Lao, where words are not separated by spaces. In those writing systems, ZWS provides a hint to text rendering engines about where line breaks are acceptable, without introducing a visible gap.
Over time, developers adopted Zero Width Space for broader web use cases. It became a tool for controlling line-breaking behavior in HTML, creating invisible placeholders, and even implementing lightweight copy-protection techniques. The character is part of the broader Unicode category of "formatting characters," alongside direction marks, invisible operators, and other non-printing code points.
HTML Entity Code
You can insert Zero Width Space in HTML using any of these methods. Each approach works in different contexts, so knowing all of them gives you flexibility depending on whether you are writing static HTML, generating content with JavaScript, or styling with CSS.
HTML Entity (named)
​ HTML Entity (numeric decimal)
​ HTML Entity (hexadecimal)
​ JavaScript Unicode Escape
​ JavaScript Unicode Code Point
String.fromCodePoint(0x200B) CSS Content Property
content: '\200B'; Python
​ Common Use Cases in HTML
1. Preventing Trailing Space Removal
Browsers collapse trailing whitespace by default. If you need to preserve a trailing space in rendered text—for example, in a code display or a specific layout—adding a Zero Width Space at the end keeps the space intact without introducing a visible character. This is particularly useful in preformatted text blocks where trailing spaces are meaningful, or when working with CMS content that strips trailing whitespace during sanitization.
2. Line Breaking in Long Words
Long URLs, technical terms, or compound words can overflow their containers on narrow screens. By inserting Zero Width Space at logical break points within the word, you give the browser permission to wrap the text at those positions. For instance, a URL like https://example.com/very/long/path can be broken after the domain or between path segments without adding visible hyphens or spaces.
3. Invisible Placeholders
Some form validation systems and content management platforms require non-empty fields. Zero Width Space lets you satisfy those requirements with content that appears blank to users. This is also useful for empty table cells, padding in data grids, or maintaining structural integrity in markup that demands at least one character per element.
4. Copy-Paste Protection
Embedding invisible characters in text creates a subtle watermark. When someone copies your content, the Zero Width Spaces travel along with it. While this is not foolproof—determined users can strip them—it adds a lightweight layer of attribution tracking. Some publishers use this technique to identify which publication originally syndicated an article based on where the invisible markers appear in the copied text.
5. Text Sorting and Ordering
In some sorting algorithms, Zero Width Space can be used to break ties between otherwise identical strings. By appending ZWS characters in specific positions, you can control the sort order of items that would otherwise be indistinguishable. This is a niche but practical technique in data display scenarios.
Code Example
Here are practical examples showing how Zero Width Space works in real HTML and JavaScript scenarios.
<!-- Break a long URL at logical points -->
<p>
Visit​https://example.com/very/long/path/that/should/wrap
</p>
<!-- Preserve trailing space in a heading -->
<h1>Welcome​</h1>
<!-- Invisible placeholder for form validation -->
<input type="text" value="​" />
<!-- Word break inside a compound term -->
<p>
super​cali​fragilistic​expialidocious
</p>
<!-- JavaScript: dynamically insert ZWS -->
<script>
const ZWS = '\u200B';
const longWord = 'antidisestablishmentarianism';
const breakable = longWord.split('').join(ZWS);
document.getElementById('output').textContent = breakable;
</script>
<!-- CSS: insert ZWS via pseudo-element -->
<style>
.watermark::after {
content: attr(data-zws);
position: absolute;
width: 0;
height: 0;
overflow: hidden;
}
</style>
<!-- Python example -->
# Insert ZWS between every character
text = "Hello World"
zws = "\u200B"
breakable = zws.join(text)
print(breakable) # H\u200Be\u200Bl\u200Bl\u200Bo\u200B \u200BW\u200Bo\u200Br\u200Bl\u200Bd Browser Compatibility
Zero Width Space is part of the Unicode standard, not a browser-specific feature. This means support is universal across all browsers and operating systems that handle Unicode text. Here is a detailed breakdown:
| Browser | Support | Notes |
|---|---|---|
| Chrome | Full | Works since Chrome 1+ |
| Firefox | Full | Works since Firefox 1+ |
| Safari | Full | Works since Safari 1+ |
| Edge | Full | All versions, including legacy EdgeHTML |
| IE 11 | Full | Full Unicode support including ZWS |
| Mobile Safari | Full | iOS Safari, Chrome for iOS |
| Android Browser | Full | Chrome for Android, Samsung Internet |
One thing to keep in mind is that screen readers may behave differently with Zero Width Space. Some assistive technologies skip it entirely, while others may announce it as a "space" or "blank." If accessibility is a concern, test your implementation with NVDA, VoiceOver, and JAWS to ensure the character does not produce unexpected announcements.
Zero Width Space vs Other HTML Spaces
HTML provides several space-related characters, each with distinct behavior. Understanding the differences helps you choose the right one for your use case.
| Character | Code | Width | Primary Use |
|---|---|---|---|
| Regular Space |   | Variable | Standard word separator |
| Non-Breaking Space | | Fixed | Prevents line break, preserves width |
| En Quad |   | Half em | Typographic spacing |
| Em Space |   | Full em | Paragraph indentation, wide gaps |
| Thin Space |   | 1/5 em | Narrow typographic spacing |
| Hair Space |   | Very thin | Minimal spacing adjustments |
| Zero Width Space | ​ | Zero | Line break hints, invisible markers |
The key difference between Zero Width Space and non-breaking space is their purpose: keeps words together and adds visible width, while ZWS allows line breaks and adds no width. Use non-breaking space when you want to prevent wrapping (like "100 km/h"), and use Zero Width Space when you want to allow wrapping in places where the browser would not normally break.
SEO Considerations
Search engines treat Zero Width Space with caution. Google's indexing systems generally ignore invisible characters when parsing page content, but there are nuances worth understanding.
Keyword stuffing risk. If you embed Zero Width Spaces inside keywords to create variations that users cannot see—for example, writing "shoes" to rank for both "shoes" and "shoes" with different spacing—search engines may flag this as manipulative. Google's spam detection systems are designed to identify and penalize such tactics.
Content extraction. When crawlers extract text from your HTML, Zero Width Spaces are typically stripped out. This means your visible content is what matters for indexing. ZWS used for layout purposes (like line breaking) will not affect your search rankings positively or negatively.
Hidden text policy. Google's webmaster guidelines prohibit hiding text from users while making it visible to search engines. Zero Width Space alone does not trigger this penalty since it does not hide text—it merely affects line breaking. However, combining ZWS with CSS techniques like display: none or font-size: 0 to conceal keyword-stuffed content will result in penalties.