Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide text in H1 tag but not the image

Tags:

html

css

hide

I need to hide the text inside a H1 tag. But not the image. Problem is that i only can change the css and not the html

<h1>
<img src="img/headerimg.png" width="900" height="125"/>
Header 1 text
</h1>

Is there a way to only hide the "Header 1 text" with only css? I'm doing this for big client and they gave me only acces to the css file.

like image 591
user1386906 Avatar asked Dec 03 '22 01:12

user1386906


2 Answers

Give a 0px font size

​h1{ font-size:0px }​

Edit: Working sample

like image 101
hkutluay Avatar answered Dec 21 '22 23:12

hkutluay


Set the image as background of the <h1>, add CSS properties to the <h1> to make it the size of the image and use a negative text-indent on the headline to remove the text. That would be the usual and ideal way to do it if you had access to the html too.

Since you only have access to the CSS, you can use this:

h1 {
    font-size: 0.1px; /* 0 gets disregarded by Internet Explorer, 0.1 gets interpreted right by every browser */
}

Fiddle: http://jsfiddle.net/VGgnD/

like image 40
Markus Unterwaditzer Avatar answered Dec 22 '22 00:12

Markus Unterwaditzer