Skip to main content
    Web Development

    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

    CharacterEntityNumericCopy
    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>&#8203;<span>World</span>

    Prevent Line Break

    Non-breaking spaces keep words on same line

    <!-- Keep words together -->
    <span>New&nbsp;York&nbsp;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">&#8203;</span>
      <span class="sr-only">Close menu</span>
    </button>

    Best Practices

    Do

    • • Use &nbsp; to prevent word breaks
    • • Use .sr-only for accessible hidden text
    • • Use zero-width spaces for word break hints
    • • Test hidden content with screen readers

    Don't

    • • Use display: none for SEO text
    • • Hide important content from users
    • • Use invisible text for keyword stuffing
    • • Use visibility: hidden for 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 &nbsp; and a regular space?

    A regular space allows line breaks and collapses multiple spaces into one. &nbsp; (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 (&#8203;) or a non-breaking space (&nbsp;). 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.