16

Any ideas why?

http://jsfiddle.net/FHUb2/

.dashboard-edit,
.dashboard-delete {
  height: 30px;
  width: 50px;
  background: url("https://i.stack.imgur.com/kRZeB.png") no-repeat top left;
  text-indent: -9999px;
}
<a href="#" title="Edit" class="dashboard-edit">Edit</a>
<a href="#" title="Delete" class="dashboard-delete">Delete</a>
Gleb Kemarsky
  • 10,160
  • 7
  • 43
  • 68
ilyo
  • 35,851
  • 46
  • 106
  • 159

6 Answers6

67

Apart from the reason that text-indent doesn't works on inline elements. another reason is if your element or one of its parent has been set with text-align:right

So make sure your element has been set with text-align:left to fix this.

asumaran
  • 977
  • 1
  • 8
  • 16
51

text-indent does not work on inline elements and <a> is an inline element so you can define display:block or display:inline-block to your <a> tag.

.dashboard-edit,
.dashboard-delete {
  height: 30px;
  width: 50px;
  background: url("https://i.stack.imgur.com/kRZeB.png") no-repeat top left;
  text-indent: -9999px;
  display: inline-block;
}
<a href="#" title="Edit" class="dashboard-edit">Edit</a>
<a href="#" title="Delete" class="dashboard-delete">Delete</a>
Gleb Kemarsky
  • 10,160
  • 7
  • 43
  • 68
sandeep
  • 91,313
  • 23
  • 137
  • 155
7

<a/> tags are not 'blocks'

add the following:

display: inline-block;
Bart Vangeneugden
  • 3,436
  • 4
  • 33
  • 52
5

In my case text indent was not working on H1 because of :before pseudo tag I used to correct a fixed header positioning problem

.textpane h1:before, .textpane h2:before, .textpane h3:before {
  display:block;
  content:"";
  height:90px;
  margin:-90px 0 0;
}

This applied to H1 elements with negative indent hack showed text on top of the images in FF & Opera

Community
  • 1
  • 1
Janusz Skonieczny
  • 17,642
  • 11
  • 55
  • 63
2

Keep in mind that (if you care) with inline-block the text-indent image replacement technique will fail in IE7. I recently had a heck of a time figuring that one out. I used this technique for IE7 and it works:

.ir {
    font: 0/0 a;
    text-shadow: none;
    color: transparent;
}
Gabriel Luethje
  • 387
  • 5
  • 14
0

I had same issue, I checked display and text-align. finally I find out.

I was working on rtl design and in the theme the direction changed to rtl.

You can change the container or each element to ltr to fix the issue.

dashboard-edit, .dashboard-delete { 
    direction: ltr;
}
Nader
  • 933
  • 1
  • 7
  • 8