View Full Version : validator is telling me "name" is not a valid attribute for <img />

10-22-2004, 04:28 PM
am i drunk or is the validator plum loco?

i see name listed here (http://www.w3.org/TR/html401/struct/objects.html#edef-IMG), so i am confoozed

p.s. HTML 4 Transitional

10-22-2004, 04:41 PM
I reckon it's something else... Typo maybe? Invalid char?


And the validator won't allow <img /> in HTML 4.01 transitional if that's how you're using it... I closed the tag out of habbit and it told me not to.

10-22-2004, 04:48 PM
No, I know the element doesn't need closing. I just write that way in "conversation" online often times because I tend to think in terms of XHTML not HTML.

At any rate, the offending tag:

<img name="home" src="images/nav_home_up.gif" alt="Home" width="196" height="35">

No typos here... hrm...

10-22-2004, 04:50 PM
Well I've replaced my image tag with yours, and mine still validates. How about the entire source?

10-22-2004, 05:06 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-us">
<title>Lauren Redpath</title>
<link rel="stylesheet" type="text/css" href="_redpath.css">
<script type="text/javascript" src="_redpath.js"></script>

<script type="text/javascript">
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000
// Duration of crossfade (seconds)
var crossFadeDuration = 5
// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'images/pagephotos/home/home_blue.jpg'

Pic[1] = 'images/pagephotos/home/home_white.jpg'

Pic[2] = 'images/pagephotos/home/home_yellow.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
preLoad[i] = new Image()
preLoad[i].src = Pic[i]

function runSlideShow(){
if (document.all){
document.images.SlideShow.src = preLoad[j].src
if (document.all){
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runSlideShow()', slideShowSpeed)



<body id="redpath" onload="runSlideShow()">

<div id="shell">

<h1><a href="index.cfm"><img src="images/lauren_redpath.gif" alt="LAUREN REDPATH" width="226" height="70"></a></h1>

<div id="nav">
<li><a href="index.cfm" onmouseover="navSwap('home','o')" onmouseout="navSwap('home','u')">
<img name="home" src="images/nav_home_up.gif" alt="Home" width="196" height="35">

<li><a href="music.cfm" onmouseover="navSwap('music','o')" onmouseout="navSwap('music','u')">
<img name="music" src="images/nav_music_up.gif" alt="Music" width="196" height="35">
<li><a href="news.cfm" onmouseover="navSwap('news','o')" onmouseout="navSwap('news','u')">
<img name="news" src="images/nav_news_up.gif" alt="News" width="196" height="35">
<li><a href="tour.cfm" onmouseover="navSwap('tour','o')" onmouseout="navSwap('tour','u')">
<img name="tour" src="images/nav_tour_up.gif" alt="Tour" width="196" height="35">

<li><a href="photos.cfm" onmouseover="navSwap('photos','o')" onmouseout="navSwap('photos','u')">
<img name="photos" src="images/nav_photos_up.gif" alt="Photos" width="196" height="35">
<li><a href="bio.cfm" onmouseover="navSwap('bio','o')" onmouseout="navSwap('bio','u')">
<img name="bio" src="images/nav_bio_up.gif" alt="Bio" width="196" height="35">
<div id="newsletterSignup">

<form id="signup" method="post" action="index.cfm">
<legend><img src="images/fanclub_subscription.gif" alt="Fanclub Subscription" width="196" height="15"></legend>

<label for="email">
Enter email address!
<input type="text" name="email" id="email">
<label for="name">Enter name!</label>
<input type="text" name="name" id="name">

<input type="submit" name="submit" id="submit-signup" value="Sign Up" class="button">


<div id="content">

<img src="images/pagephotos/home/home_yellow.jpg" alt="" width="348" height="384" id="SlideShow" name="SlideShow">




10-22-2004, 05:22 PM

I only had to add <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

And even before that, all it complained of was a missing charset.

So then... You using another validator, or maybe they sorted the bug since you posted? Heh. Spooky.

Oh, and that's an HTML 4.01 strict doctype you're using there... This the right source?

10-22-2004, 05:27 PM
Well, that meta tag doesn't really matter. Server sends appropriate headers and what not without it.

I'm still getting this under the Transitional DOCTYPE, but interestingly enough... not under Strict...

Unfortunately, I need to allow target attributes on <a>s so I gotta keep diggin', I guess...

(Yeah dude, I just noticed... I been switching things up all over this morning... working on that issue, trying to finish a custom CF tag to automatically wrap URLs in <a href=""></a>, etc... there may or may not be a method to my madness, but mad it certainly can be... but yes, validates with Strict, but not with:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"


10-22-2004, 05:35 PM
I switched the doctype on that source you gave me to transitional and it still validates? Heh.

Custom CF tag? Oh, hehe. Just hit me as I typed that. ColdFusion? I wrote a handy regex that'll replace links in a string, but it uses the eval modifier which may or may not be PHP-only...

Did you sort the name thing or no? Stuff like this pretty much calls for removing everything except the problem tag, seeing if it validates, and then adding bit by bit until it stops validating.

10-22-2004, 05:47 PM
Yeah, it's ColdFusion. That's what we use here at work. If only CF weren't so damned expensive, I'd just do all my personal stuff in that too because I'm much more proficient with it than PHP at this point... but I digress...

I suppose I'll try that, stripping everything else out. I'll report back later... ;)

10-22-2004, 06:08 PM
Man, the validator is frustrating me this morning. I switched the DOCTYPE sitewide, and I was validating part of the back end and despite my double and triple checking that the DOCTYPE is now Transitional, it is telling me the document is valid Strict...


10-22-2004, 06:52 PM
Tell the validator to "Show Source" to see what it's seeing.

10-22-2004, 07:01 PM
Yes, good call... fortunately(or unfortunately, i can't tell anymore...) it's now seeing Transitional and giving me the name error I haven't yet tried to filter out...