Extract 'ALT' Text from HTML into a Plain Text File and Insert it Back into HTML Again

(Version 1 & 3 respectively)

What Are They?

They are programs which extract 'ALT' text from an HTML document to a normal plain text file for easy editing and put it back into the HTML document again afterwards.

System Requirements

A Perl interpreter.

How to Use It

To Extract 'ALT' Text

Run 'HtmlImgAltTextExtract.pl'. It takes one parameter: the name (path with respect to current working directory) of the HTML file to extract from.

It will copy the 'ALT' text it finds in that file into a file with the same name as the HTML file but with 'AltText.txt' appended. It will not alter the original HTML file.

Text File Format

It is a very simple format. For each image the entry consists of:

  1. The address of the image as written in the HTML. Followed by a line break.
  2. The 'ALT' text. Followed by two line breaks.

To Insert 'ALT' Text

Run 'HtmlImgAltTextInsert.pl'. It takes two parameters: the names (paths with respect to current working directory) of the HTML file to insert into and the text file containing the 'ALT' texts to be inserted respectively.

Example Uses

As well as making editing the ALT text in an HTML document less cumbersome that editing the HTML source in a text editor or opening up a dialogue box for each image in a WYSIWYG HTML editor, it can be used for:

Known Deficiencies


Other Perl Scripts, Disclaimers Etc.

See my computer programs index page for more simple useful computer programs.

Appendix: What is 'ALT' Text?

'ALT' text is the text alternative for an image in an HTML page.

It is written into the HTML <IMG> element, which specifies an image, by the value of its ALT (short for 'alternative') tag; hence its common name of 'ALT' text. For example <IMG SRC="Halibut1.jpg" ALT="An underwater photograph of a halibut swimming to the left."> would tell the web browser to display the JPEG image of the fish if it could display image or the text description of the fish if not.

Almost all images on web pages should have useful text alternatives because not all web browsers can usefully display images. For example, they might be running over very slow network links (e.g. mobile telephone modems), have small screens or the user might be blind (if you are making commercial web pages then you really need to take this into account as disabled accessibility is probably a legal requirement in addition to a way of increasing your customer base). Text alternatives also improve the chances of people finding your pages in the fist place because current web search engines are virtually all text based, not image based, even when they are being used to search for images.