Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS property "text-indent" not working with html span element

Tags:

For example:-

HTML Code

<div>      <h1><span class="title-icon">icon</span> Hello India!</h1> </div> 

CSS Code

h1{ }  h1 span{     background: url("../images/icon.png")     text-indent: -9999px;     width:24px;     height:24px;     margin-right:1em; } 
like image 570
Bipin Kumar Pal Avatar asked Aug 09 '13 10:08

Bipin Kumar Pal


2 Answers

text-indent doesn't work on inline elements. <span> defaults to being inline. You need to change it so it works as an inline block:

display:inline-block; 
like image 179
Spudley Avatar answered Sep 27 '22 17:09

Spudley


Try setting font-size to zero:

h1 span {     background: url("../images/icon.png")     font-size: 0;     width: 24px;     height: 24px;     margin-right: 1em; } 
like image 39
Vladimir Bozic Avatar answered Sep 27 '22 19:09

Vladimir Bozic