473,404 Members | 2,137 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,404 software developers and data experts.

img element: src and alt attributes


Hello,

I would like to know whether it is possible to use cascading
style sheet language to set the values of the src and alt
attributes of an img tag. This would come in handy in
situations where you want to display an image in
several places by referencing it by its class
attribute for conciseness.

Please let me know,

Best Regards,

Thanks,

Neil

Jul 21 '05 #1
3 8607
In our last episode,
<11**********************@l41g2000cwc.googlegroups .com>,
the lovely and talented nz******@cs.mun.ca
broadcast on comp.infosystems.www.authoring.stylesheets:

Hello, I would like to know whether it is possible to use cascading
style sheet language to set the values of the src and alt
attributes of an img tag. This would come in handy in
situations where you want to display an image in
several places by referencing it by its class
attribute for conciseness.
Not really. You can put the image in a stylesheet by making it
the background of a box and simulate an alt text with text in
your document that you hide. And this can actually be sort of
seamless-looking in text browsers.

But what you really want is not to be typing the
IMG tag in over and over. What you want is a preprocessor.
Here is how I enter am image (one I call shortname for this
example) in my preprocessed document:

%getimage(%location,shortname,&pagereg)

This is simpler than that, because I taught my editor a macro
to prompt me for the shortname when I hit meta-q g, and it
writes the line. The preprossor looks up shortname in a
database of images, writes the IMG tag, writes the markup
and caption (if there is a caption in the database) and
records the use of the image in a text file which will be
used by macros in the footer to lookup the photo credit
to put it in the footer and in the stylesheet to look up
height, width, and any special styles for the image. Naturally
the footer gets preprocessed after the body of the document,
and the only tricky thing is to be sure the stylesheet is
in the Makefile *after* the document.

%location is a variable I set at the top of every document
that says where the document is. The %getimage preprocessor
macro then will get the path in the IMG src attribute right
no matter what directory the document is in.
Please let me know,


Preprocessor.
--
Lars Eighner ei*****@io.com http://www.larseighner.com/
Nobody home but the lights, and they're out too.
Jul 21 '05 #2
"" wrote in comp.infosystems.www.authoring.stylesheets:
I would like to know whether it is possible to use cascading
style sheet language to set the values of the src and alt
attributes of an img tag.


CSS doesn?t _do_ anything. The first and most important lesson to
larn about CSS is that it is not a scripting language and can?t be
used to alter Web pages.

--

Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
Jul 21 '05 #3
nz******@cs.mun.ca wrote:
I would like to know whether it is possible to use cascading
style sheet language to set the values of the src and alt
attributes of an img tag. This would come in handy in
situations where you want to display an image in
several places by referencing it by its class
attribute for conciseness.

Please let me know,


Yes you can show images based on css class attribute and 'attach' image
to css class attribute by using the css generated content url function,
but this will work in no way in MSIE6, which users are probably 90% of
your audience. It works by Opera, probably which of you have only 1%
visitors.

Physically it can be done, but in nowadays reality you cant do that, as
the amount of Opera browser users is almost unexistant and the MSIE
dominates.

--
Marek Mänd
Estonia, Tallinn
Jul 21 '05 #4

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

Similar topics

3
by: Pat | last post by:
Hi all, In contruction of DTD for a scenario, what are the rules/guildelines to determine if certain piece of information should be stated as child element or an attribute? I read some...
9
by: Joris Gillis | last post by:
Hi everyone, I was wondering... Can one element have multiple (identically named) attributes in XML? e.g. Is the following document valid XML? <?xml version="1.0" encoding="UTF-8"?> <root...
2
by: Robert Zurer | last post by:
I want to create a schema element that will allow any element as a child but that child must contain specified attributes This example doesn't work but it might give an idea of what I need to do....
2
by: Tom Kerigan | last post by:
I know that longer element names increase the size of an XML document, ultimately resulting in a larger amount of data at parse-time. Is there anything else, specifically related to an element name...
1
by: Tod Johnson | last post by:
Hello all, Can't figure it out. :( Assume that we have 2 XML document: Document1 (source): <elements> <elementA attribute1="value1" attribute2="value2" ... /> <elementA attribute1="value1"...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
4
by: Mike | last post by:
I have a web service being consume by a new client. The WebMethod they are calling is called Process. So in the WSDL I have has 2 elements, Process and ProcessResponse. <s:schema...
3
by: namewitheldbyrequest | last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/' is already present in the current scope" I created a Web Service: I imported System.Data.SqlClient so I could access SQL...
14
by: kelvin.jones | last post by:
Hi, if I had the ID of an input element, how can I find the input's FORM in javascript? Basically, given a input's dom id, I want to insert something in the onSubmit of the Form that that input...
2
by: cloftis | last post by:
Using VS2003, VB and MSHTML, Using an HTMLSpanElement I want to enumerate the attributes of a SPAN tag. 1 'For testing sake 2 Dim strMarkup as String = "<span attr1='somevalue'...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.