![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want to move the image for a link from the HTML to the CSS, but cannot figure out how to do it. |
|
Here is the old HTML: a href="somewhere.html"><img src="anImage.gif"/></a The image is 18x48 |
#3
| |||
| |||
|
|
CSS is for presentation, not content. You cannot do it with CSS unless you want it to be a background image. |
#4
| |||
| |||
|
|
On Sep 22, 7:30 pm, "Chris F.A. Johnson" <cfajohn... (AT) gmail (DOT) com> wrote: CSS is for presentation, not content. You cannot do it with CSS unless you want it to be a background image. Exactly, I am trying to figure out how to make it the background image of the link. What I am trying to do is move all the presentation formatting to the CSS, including the images. The ultimate objective is to be able to change the CSS file and change the whole theming of the site. |
#5
| |||
| |||
|
|
On Sep 22, 7:30 pm, "Chris F.A. Johnson" <cfajohn... (AT) gmail (DOT) com> wrote: CSS is for presentation, not content. You cannot do it with CSS unless you want it to be a background image. Exactly, I am trying to figure out how to make it the background image of the link. What I am trying to do is move all the presentation formatting to the CSS, including the images. The ultimate objective is to be able to change the CSS file and change the whole theming of the site. |
#6
| ||||
| ||||
|
|
But if you use text and a background image, it is likely that you will run into accessibility issues in the case CSS is supported and the "presentational" background image can be perceived by the user (e.g. bad contrast and scaled fonts). |
|
And if you put the text into the image and make the content transparent |
|
it is not unlikely that this will be (mis)recognized by search engines as an attempt to trick them, therefore being ignored as well and your site maybe blacklisted. |
|
So you you better stick with the `img' element, and provide the `alt' attribute. |
#7
| |||||||
| |||||||
|
|
Thomas 'PointedEars' Lahn wrote: But if you use text and a background image, it is likely that you will run into accessibility issues in the case CSS is supported and the "presentational" background image can be perceived by the user (e.g. bad contrast and scaled fonts). ? If you mean the text is in the background image, then that can most definitely be a problem. |
|
However, plain text links styled with a background image can be very accessible, providing they are done correctly. A patterned bg can certainly pose a readability problem, but common effects like drop shadows are not. Look up 'CSS sliding doors' for example. |
|
And if you put the text into the image and make the content transparent Are you referring to image replacement? That's the common term for hiding foreground text with background images via various CSS techniques. |
|
alternative</a |
|
IR was originally developed strictly to benefit search engines and pretty much all methods have some kind of accessibility problem. |
|
it is not unlikely that this will be (mis)recognized by search engines as an attempt to trick them, therefore being ignored as well and your site maybe blacklisted. I wouldn't go that far, though keyword spamming may get you blacklisted no matter how you do it. |
|
So you you better stick with the `img' element, and provide the `alt' attribute. I think it really depends on the context, which the OP hasn't provided. |
#8
| ||||
| ||||
|
|
Bergamot wrote: plain text links styled with a background image can be very accessible, providing they are done correctly. the OP posted a link that contained only one `img' element. That would mean that the image would have conveyed the meaning of the link. |
|
I have explained why that element can not be substituted by a background image. |
|
a href="..." style="background: url(...) no-repeat; color: transparent" alternative</a |
|
I think it really depends on the context, which the OP hasn't provided. They have provided enough to make an educated guess. |

#9
| ||||||||
| ||||||||
|
|
Thomas 'PointedEars' Lahn wrote: Bergamot wrote: plain text links styled with a background image can be very accessible, providing they are done correctly. the OP posted a link that contained only one `img' element. That would mean that the image would have conveyed the meaning of the link. But since the OP did not include any alt text for that image or the context of its use, let alone a link to the graphic itself, you're making an assumption that it is not a picture of text. |
|
I'm assuming it is, as in a navigation menu with graphical "buttons", which are easily done using plain text links styled with CSS. |
|
I have explained why that element can not be substituted by a background image. It depends on the context and we don't know what that is. |
|
Here is the old HTML: a href="somewhere.html"><img src="anImage.gif"/></a The image is 18x48 |
|
Besides, you seem to think that the same image used as foreground content must be used as a background graphic instead. That may not be necessary at all. |
|
a href="..." style="background: url(...) no-repeat; color: transparent" alternative</a "transparent" is not a valid value for the color property, |
|
so browser rendering would surely be unpredictable. |
|
I've seen lots of different image replacement methods, but never seen this one attempted. |
#10
| |||
| |||
|
|
I want to move the image for a link from the HTML to the CSS, but cannot figure out how to do it. |
![]() |
| Thread Tools | |
| Display Modes | |
| |