Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I hide anchor text without hiding the anchor?

Tags:

css

Say I have the following markup:

<li><a href="somehwere">Link text</a></li> 

If I have a background image on the a tag, how would I hide the link text using just css? font-size:0 seems to work fine on the a tag apart from in ie7 little blobs show.

  • Thanks for help so far I have used line-height: 0; and font-size: 0; and text-indent: -999px. But it still shows up some blobs in safari, any ideas?
like image 429
geoffs3310 Avatar asked Mar 14 '11 15:03

geoffs3310


People also ask

How do I hide an anchor tag?

To disable a HTML anchor element with CSS, we can apply the pointer-events: none style. pointer-events: none will disable all click events on the anchor element. This is a great option when you only have access to class or style attributes. It can even be used to disable all the HTML links on a page.

How do you hide a link in text?

Wrap the text in a span and set visibility:hidden; Visibility hidden will hide the element but it will still take up the same space on the page (conversely display: none removes it from the page as well).

How do I hide text tags in CSS?

visibility:hidden , color:transparent and text-indent will do this. the font-size:0 option will work better I think. It should be remembered that some of these solutions will only hide the text. They will still leave a space for it on the screen.

How do I hide text in span?

You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid. A hidden <span> element is not visible, but it maintains its position on the page. Removing the hidden attribute makes it re-appear.


2 Answers

Try

 a{     line-height: 0;      font-size: 0;     color: transparent;   } 


The color: transparent; covers an issue with Webkit browsers still displaying 1px of the text.

like image 79
Loktar Avatar answered Oct 13 '22 06:10

Loktar


Wrap the text in a span and set visibility:hidden; Visibility hidden will hide the element but it will still take up the same space on the page (conversely display: none removes it from the page as well).

like image 45
scrappedcola Avatar answered Oct 13 '22 04:10

scrappedcola