tags:

views:

83

answers:

6

I want to know what the difference is between alt="" and name=""

Would it be better to put the filename within the alt tag, or the description of the photo?

What makes better sense, both from SEO and validation stand-point?

+5  A: 

Using the ALT attribute is more useful in terms of search engine optimalisation. Using the NAME attribute is mainly useful for internal page anchors.

The ALT attribute is intended to provide an alternate text that describes the image for people who use screen-readers, or search engines, for example.

The name attribute is mainly used for internal anchoring, which allows you to navigate within a page using anchors.

Example usage of the name attribute:

<!-- following ancor can be referenced as http://&lt;your_url&gt;#post-123 -->
<a name="post-123">permanent link to some post</a>

Example usage of alt attribute:

<!-- following image shows "FooBar Company Logo" when images can't be shown -->
<img src="logo.jpg" alt="FooBar Company logo" />
Aron Rotteveel
I may have got this wrong, but is it not the case that ALT does not work this way on Firefox?
Ben
+1  A: 

I'd be a little wary of putting the file name in the ALT tag, since it would be displayed if images are turned off. Typically you set the ALT tag to server as a place holder with something like "Site Logo" or something else to indicate what the image is.

The NAME tag is used for anchoring and the like. If you wanted to create a link that scrolled a long page to your image, you would reference it through this.

Dillie-O
+1  A: 

Yeah, definitely put a description in the alt tag. It is really important for the visually impaired as this is what the screen readers will read when they come across an image. The only potential catch with this is that the alt tag is treated as tool tip text by some browsers, however, you can override that behavior with setting title="".

Brian Fisher
+1  A: 

The alt attribute is intendet to supply an descriptive alternative in text form for the image. So if you have an image that shows a sunflower, you could use:

<img src="sunflower.jpg" alt="image of a sunflower on a sunny day">

The name attribute in intended to name the image for scripting so you can access it using images["sunflower"]. But nowadays you should use the id attribute instead.

Gumbo
+1  A: 

You definitly want to use the ALT tag - for all the reasons mentioned above, and: this tag is mandatory according to W3C so you need it if you want to create "compliant code" (see e.g. w3schools).

ISW
+2  A: 
  • The name attribute exists only to provide a name to refer to in JavaScript.
  • The alt attribute provides an alternate description for search engines, blind people, when the image could not be loaded, etc.
  • The title attribute provides a description which will be shown when the user hovers over the image with his mouse - some (but not all) browsers will use the alt attribute for this purpose when there is no title
Michael Borgwardt