/    Sign up×
Community /Pin to ProfileBookmark

Alt tag in css tylesheet??

I have several divs with background urls… Is there a way to have an alt tag in the CSS stylesheet so a description pops up with a mouseover?

to post a comment
CSS

10 Comments(s)

Copy linkTweet thisAlerts:
@pyroDec 13.2003 — No. And further, the alt attribute is to supply alternate text for images, for non-graphical browsers, or when the image is not available. IE, unfortunatly, seems to think the alt attribute is the title attribute. If you want the little description box, use the title attribute -- that's what it's for.
Copy linkTweet thisAlerts:
@MattchuBauthorDec 13.2003 — And the title attribute can be used in the CSS stylesheet? How is it supposed to look?
Copy linkTweet thisAlerts:
@pyroDec 13.2003 — [b]Neither[/b] attribute are css -- they are HTML attributes.

<div title="foo">blah</div>

<img src="foo.png" width="50" height="50" alt="description of foo.png">
Copy linkTweet thisAlerts:
@MattchuBauthorDec 13.2003 — Okay, so it can't be done in just the stylesheet then.

What I want to do is something like this:

div.abc {

background:url(blahblah.jpg) alt="tootiefruitie"

}

Is there a way to do this? I don't want to access the html file at all. I want to be able to do everything from the stylesheet.
Copy linkTweet thisAlerts:
@pyroDec 13.2003 — No, you can not set the alt attribute via css.
Copy linkTweet thisAlerts:
@MattchuBauthorDec 13.2003 — And there is no way to do anything like that? With a description popup?
Copy linkTweet thisAlerts:
@pyroDec 13.2003 — I fail to see why you can not just put it into your markup. ?
Copy linkTweet thisAlerts:
@MattchuBauthorDec 13.2003 — I could, but I want to put it in the stylesheet. It's not a big deal, I can put it in the markup or just leave it out entirely. Thanks though.
Copy linkTweet thisAlerts:
@pyroDec 13.2003 — Sure thing...
Copy linkTweet thisAlerts:
@Robert_WellockDec 15.2003 — The answer was yes you could have used CSS to display alternative text (not how you had it though) in most circumstances it is best left to the mark-up and title attribute.

But it is impossible to use the CSS style sheet to do everything, though XSLT is probably the nearest you'll get to that scenario.
×

Success!

Help @MattchuB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...