View Full Version : adding alt in CSS
emanuelle
05-14-2008, 06:30 AM
I have an image as background image andit is in a class in my .css file. Now I need to put an alt on that picture.
Can I do it in the css?
example:
.header{float:left;display:inline;width:937px;height:74px;text-align:right;background:transparent url('../images/header_bg.gif') no-repeat;}
this image needs an alt
jscheuer1
05-14-2008, 06:48 AM
Technically speaking, it doesn't need an alt. Only image and area (perhaps one or two other) tags require an alt. Why would you want one? And no, there is no way to add an alternate attribute (or any attribute) via css. Css is only for assigning style property/value pairs.
If you mean that when you move your mouse over the .header element you want a tool tip sort of thing to come up at the mouse pointer, you can give the .header element a title attribute:
<div class="header" title="You are Pointing at my Header">Whatever</div>
If a background image is missing, it simply isn't seen. If you want an alternate text for when it is missing, you must use an image tag for it. This usually can be done, especially as this is a no-repeat background image, by positioning its image tag absolutely or relatively and behind whatever it was originally the background for.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.