473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Show alt text instead of image through CSS

On my pages, I use a couple of images (with appropriate alt texts of
course) for decoration purposes. For example:

<p>
Blablabla about some topic.<br>
<a href="foo.html">
<img src="see.gif" alt="See:">More info on bla...
</a>
</p>

where the image see.gif could be an arrow, or a pointing finger, or
whatever.

Now I'm trying to make a stylesheet for handheld media, and in this
case, I'd rather use the alt text than the image. Is there a way in CSS
to suggest showing the alt text rather than the image? You can add the
alt text after the image with:

img[alt="See:"]:after {content: attr(alt);}

(or using a class if you don't want to rely on the [alt=] selector).
But this still keeps the image itself. With "display: none" you see
nothing at all. Is there another solution?

It may perhaps be better to do it the other way around, and to use
something like Fahrner image replacement. But that has the disadvantage
of being inaccessible for screen readers, frustrating "find in page"
features, etc.

Any ideas?

--
Garmt de Vries.

Nov 2 '05 #1
1 6648
"Garmt de Vries" <gd*****@hotmail.com> wrote:
On my pages, I use a couple of images (with appropriate alt texts of
course) for decoration purposes.
Images are content in which case they should have alt content, or
decorative in which case they should have empty alt content (if coded in
the HTML at all).
For example:

<p>
Blablabla about some topic.<br>
<a href="foo.html">
<img src="see.gif" alt="See:">More info on bla...
</a>
</p>

where the image see.gif could be an arrow, or a pointing finger, or
whatever.
"More info on bla..." more than suffices semantically, adding the "See:"
prefix only degrades the semantics. Treat the image as decorative with
alt="".
Now I'm trying to make a stylesheet for handheld media, and in this
case, I'd rather use the alt text than the image. Is there a way in CSS
to suggest showing the alt text rather than the image? You can add the
alt text after the image with:

img[alt="See:"]:after {content: attr(alt);}

(or using a class if you don't want to rely on the [alt=] selector).
But this still keeps the image itself. With "display: none" you see
nothing at all. Is there another solution?


img{content:attr(alt)} CSS3, not widely supported.

--
Spartanicus
Nov 2 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Steve Speirs | last post by:
Hi I'm trying to show/hide a simple piece of text and a text field on a form based on what choice is made from a drop down box. <select name="dropdown" size="1"> <option selected...
7
by: ABC | last post by:
I am a total newbie to javascript. I have only done Frontpage. I am trying to do a page of image show----I only managed to find a javascript to create pop up windows for the chosen image. Almost...
2
by: J Sahoo | last post by:
Hi, I have a browse page where I am showing few fields from my SQL Server table. One of the field is Image type, all the fields are bound to a single table. I want to show the image from the...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
3
by: aldonnelley | last post by:
Hi all. Just having a weird problem with tkinter. I'm trying to make a gui that shows results from an image search, with a "forward" and "back" button so the user can compare results from...
0
by: K B | last post by:
Hi, I would like to show an image in the text position of radiobuttonlist listitems. Not from a dataset, just set in the html or code behind. Example (x = radio button) x Red light image...
2
elamberdor
by: elamberdor | last post by:
Hi All! Well, i'm modifying a dynamic map, with lat and long datapoints, my problem is it loads in text perfectly onto exact points I specify on the map, ..well now I want to load in...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.