473,396 Members | 1,770 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,396 software developers and data experts.

How can i set the alt attribute of all img tags in a page

Hello, how are you? I need to set a default value into all the alt
attributes in my pages (ie: <img alt="".../), I have web controls
that nor are developed by me and they write img tags in my page. I
think that using javascript I can do this issue, but ¿what is the
better way?
TIA, trallon

Sep 28 '06 #1
3 12762
trallon said the following on 9/28/2006 2:13 PM:
Hello, how are you? I need to set a default value into all the alt
attributes in my pages (ie: <img alt="".../), I have web controls
that nor are developed by me and they write img tags in my page. I
think that using javascript I can do this issue, but ¿what is the
better way?
The best way is to put appropriate alt attributes in your code, either
manually (hard coded) or dynamically on the server. Putting an empty alt
attribute won't do any good.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 28 '06 #2
Randy Webb wrote:
Putting an empty alt
attribute won't do any good.
http://www.w3.org/TR/html401/struct/objects.html#h-13.8

"Do not specify irrelevant alternate text when including images
intended to format a page, for instance, alt="red ball" would be
inappropriate for an image that adds a red ball for decorating a
heading or paragraph. In such cases, the alternate text should be the
empty string ("")."

Sep 29 '06 #3
trallon wrote:
I need to set a default value into all the alt
attributes in my pages (ie: <img alt="".../),


<script type="text/javascript">
function init(){
imgs = document.images;
for(i=0;i<imgs.length;i++){
imgs[i].alt="";
}
}
</script>
<body onload="init()">

Sep 29 '06 #4

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

Similar topics

0
by: JimM | last post by:
Whenever I paste HTML code into the .Net IDE, it automatically adds an ID attribute for HTML tags in my page that don't already have one. Is there any way to stop this behaviour? Before you...
4
by: Stan Brown | last post by:
In converting my pages to 4.01 Strict, I've been removing ALIGN attributes everywhere. I was surprised to notice that a page that validated contained a <td align=left>. Sure enough, when I...
2
by: upersson | last post by:
Hi! When accessing my web page I build up the javascript and html dynamically. Depending on an parameter I want to set all the fields (input tags) readonly. How do I do this? Of course I can...
2
by: Dilip | last post by:
Hi Is there a way to modify the action attribute of a form just before the initial GET for that page renders the HTML? I have a case where I do a GET on a URL like so:...
4
by: Dabbler | last post by:
I'm trying to block out some text by setting Label width attribute which renders as a span tag so that all labels for textfields take up the same amount of space hence the textfields are all...
3
by: Hamed | last post by:
Hello I have a DataGrid object in my ASP.NET page that has the following template column. When I put the "readonly" attribute in the INPUT tag, it generates readonly="". <asp:TemplateColumn...
1
by: Heron | last post by:
Hi, I'm new to regular expressions and having troubles recreating one that would match tags with there attribute and content. Example on which i'm doing the match: protected void...
0
by: awburns | last post by:
I have a custom server control I've written, which I've subclassed from the System.Web.UI.Control class. When I drag it from the toolbar to the page, the following text is put into the aspx...
2
by: Icarus - iD_Ten_T helper | last post by:
I am currently teaching myself PHP, JS, HTML and CSS. I would say I am a beginner to interemediate at varying levels within all 4, however I have some queries and I wonder if any of you can...
4
by: nothing1 | last post by:
Ok here is my question i hope its something easy. I have CMS that generates images from whatever url I put with its corresponding syntax. Well I want to add a Lightbox to does images but instead of...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
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...

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.