HOW TO: Generate messages with the alt text of every "img" element

Post here if your topic is about CSS HTML Validator but doesn't fit in another forum.
Post Reply
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

HOW TO: Generate messages with the alt text of every "img" element

Post by Albert Wiersch »

Did you know? CSS HTML Validator is very configurable.

For example, if you want a new validator message containing the alt text used for every "img" tag then you can put the below function in a file (for example, myuserfunctions.cfg, but you can name the file whatever you want).

Code: Select all

function onStartTag_img() {
 if hasAtt('alt') {
  $altindex=getAttIndex('alt');
  Message(1, MSG_MESSAGE, 'This <img> has alt text: "' + getAttValueEx($altindex,12) + '"', getAttValueLocation($altindex));
}}
Save the file, and specify the file in the 'Config File' page of the Validator Engine Options (as a user functions file).

Screenshot of the Config File options page in the Validator Engine Options with an arrow pointing to the User functions option

Your new message will then be generated once the configuration is reloaded.

Please note that using user functions requires the Pro or Enterprise edition.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Post Reply