Invisible Text in HTML
Complete guide to using invisible characters and hidden text in HTML. Learn about entities, CSS techniques, and accessibility best practices.
HTML Invisible Character Entities
| Character | Entity | Numeric | Copy |
|---|---|---|---|
| Non-Breaking Space | |   | |
| Zero Width Space | ​ | ​ | |
| Zero Width Non-Joiner | ‌ | ‌ | |
| Zero Width Joiner | ‍ | ‍ | |
| Word Joiner | ⁠ | ⁠ | |
| Soft Hyphen | ­ | ­ | |
| Em Space |   |   | |
| Thin Space |   |   |
Code Examples
Basic Invisible Space
Zero-width space between two elements
<!-- Insert invisible space between elements -->
<span>Hello</span>​<span>World</span>Prevent Line Break
Non-breaking spaces keep words on same line
<!-- Keep words together -->
<span>New York City</span>CSS Hidden Text
Hide text with CSS while keeping it in DOM
.hidden-text {
font-size: 0;
color: transparent;
position: absolute;
left: -9999px;
}Screen Reader Only
Accessible hidden text for screen readers
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}Invisible Click Target
Invisible button with accessible label
<button>
<span aria-hidden="true">​</span>
<span class="sr-only">Close menu</span>
</button>Best Practices
Do
- • Use
to prevent word breaks - • Use
.sr-onlyfor accessible hidden text - • Use zero-width spaces for word break hints
- • Test hidden content with screen readers
Don't
- • Use
display: nonefor SEO text - • Hide important content from users
- • Use invisible text for keyword stuffing
- • Use
visibility: hiddenfor layout
SEO Warning: Using invisible text to hide keywords or content from users while showing it to search engines is against Google's guidelines and can result in penalties.
HTML Invisible Text FAQ
What's the difference between and a regular space?
A regular space allows line breaks and collapses multiple spaces into one. (non-breaking space) prevents line breaks between words and preserves multiple spaces when used consecutively.
How do I add invisible placeholder text?
Use a zero-width space (​) or a non-breaking space ( ). For accessible placeholders that screen readers can read, use the .sr-only CSS class pattern.
Can I use invisible text for SEO?
No. Using invisible text to stuff keywords is a black-hat SEO technique that violates search engine guidelines. Google can detect and penalize this practice. Only use invisible characters for legitimate purposes like preventing line breaks or accessibility.
How do I create a truly invisible element?
For visual invisibility while maintaining accessibility, use the .sr-only pattern. For complete invisibility (hidden from everyone), use display: none or the hidden attribute.