Let's say I have this element for displaying the website logo:
<div id="web-title">   <a href="http://website.com" title="Website" rel="home">     <span>Website Name</span>   </a> </div>  The #web-title would be styled with background:url(http://website.com/logohere.png), but how to properly hide the text Website Name? As seen here: Hide text using css or here https://stackoverflow.com/a/2705328 , I've seen various methods to hide the text, such as:
#web-title span { text-indent: -9999px; }  or
#web-title span { font-size: -9999px; }  or
#web-title span { position: absolute; top: -9999px; left: -9999px; }  I've also seen some combine those three methods. But actually which one is the best practice to hide text effectively?
The hidden attribute hides the <span> element. You can specify either 'hidden' (without value) or 'hidden="hidden"'.
Completely hiding elements can be done in 3 ways: via the CSS property display , e.g. display: none; via the CSS property visibility , e.g. visibility: hidden; via the HTML5 attribute hidden , e.g. <span hidden>
Actually, a new technique came out recently. This article will answer your questions: http://www.zeldman.com/2012/03/01/replacing-the-9999px-hack-new-image-replacement
.hide-text {   text-indent: 100%;   white-space: nowrap;   overflow: hidden; }   It is accessible, an has better performance than -99999px.
Update: As @deathlock mentions in the comment area, the author of the fix above (Scott Kellum), has suggested using a transparent font: http://scottkellum.com/2013/10/25/the-new-kellum-method.html.
you can simply make it transparent
{    width: 20px;    height: 20px;    overflow: hidden;     color:transparent; } 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With