Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide child element using text-indent #201

Open
mhulse opened this issue Jan 7, 2019 · 0 comments
Open

Hide child element using text-indent #201

mhulse opened this issue Jan 7, 2019 · 0 comments

Comments

@mhulse
Copy link
Owner

mhulse commented Jan 7, 2019

Using overflow: hidden and a negative text-indent can visually hide text/inline elements yet still retain their accessibility and, hopefully?, SEO goodness:

.audio {
    line-height: 1;
    text-indent: 100%;
    direction: ltr;
    white-space: nowrap;
    width: 150px;
    height: 50px;
    overflow: hidden;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    cursor: hand;
}
.audio audio {
    display: inline; /* For `text-indent` */
}
<div class="audio">
    <audio preload="none" controls autoplay hidden>
        <source src="foo.mp3" type="audio/mpeg">
    </audio>
</div>

This technique can also be used to show background images (like a logo, see #151) and hide text (useful for screen readers and/or if styles are not loaded you still get text).

Related: #145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant