trying to understand an attribute

Discussion in 'HTML' started by Richard, Jan 13, 2004.

  1. Richard

    Richard Guest

    I was looking over the info on this at w3.org and now do not understand
    this.

    I have <img name="photo.jpg" src="tree.jpg">
    W3 says, "name" is not an attribute.
    Instead, use "ID".
    Ok. So I plug in ID instead of name and I instantly get met with an error.

    While on the other hand, they plainly state that using name is perfectly ok
    for scripting purposes.
    Yet the validator keeps saying "This ain't gonna fly".
    Ok experts, which is it?
    You can't be tellin people it's a no no then turn around and say it's ok.
    It's one way or no way.
    Richard, Jan 13, 2004
    #1
    1. Advertising

  2. Richard

    Steve Pugh Guest

    "Richard" <anonymous@127.000> wrote:

    >I was looking over the info on this at w3.org and now do not understand
    >this.
    >
    >I have <img name="photo.jpg" src="tree.jpg">
    >W3 says, "name" is not an attribute.
    >Instead, use "ID".
    >Ok. So I plug in ID instead of name and I instantly get met with an error.
    >
    >While on the other hand, they plainly state that using name is perfectly ok
    >for scripting purposes.
    >Yet the validator keeps saying "This ain't gonna fly".
    >Ok experts, which is it?
    >You can't be tellin people it's a no no then turn around and say it's ok.
    >It's one way or no way.


    Let me guess. Based on your other pages you're using a HTML 4.0
    Doctype. In HTML 4.0 name was not an allowed attribute of <img>. This
    was revised in HTML 4.01.

    So, either use id and make some small changes to your code (and accept
    that the JavaScript will no longer work in some rather old browsers)
    or change your doctype to HTML 4.01 and carry on using name.

    Also be aware that whilst name does not need to be unique id must be
    unique within a document. e.g. you can have two, three, or more
    instances of name="foo" in a single document but you can only have one
    instance of id="foo".

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
    Steve Pugh, Jan 13, 2004
    #2
    1. Advertising

  3. Richard

    Gypsy Guest

    "Steve Pugh" <> wrote in message
    news:...
    > "Richard" <anonymous@127.000> wrote:
    >
    > >I was looking over the info on this at w3.org and now do not understand
    > >this.
    > >
    > >I have <img name="photo.jpg" src="tree.jpg">
    > >W3 says, "name" is not an attribute.
    > >Instead, use "ID".
    > >Ok. So I plug in ID instead of name and I instantly get met with an

    error.
    > >
    > >While on the other hand, they plainly state that using name is perfectly

    ok
    > >for scripting purposes.
    > >Yet the validator keeps saying "This ain't gonna fly".
    > >Ok experts, which is it?
    > >You can't be tellin people it's a no no then turn around and say it's ok.
    > >It's one way or no way.

    >
    > Let me guess. Based on your other pages you're using a HTML 4.0
    > Doctype. In HTML 4.0 name was not an allowed attribute of <img>. This
    > was revised in HTML 4.01.
    >
    > So, either use id and make some small changes to your code (and accept
    > that the JavaScript will no longer work in some rather old browsers)
    > or change your doctype to HTML 4.01 and carry on using name.
    >
    > Also be aware that whilst name does not need to be unique id must be
    > unique within a document. e.g. you can have two, three, or more
    > instances of name="foo" in a single document but you can only have one
    > instance of id="foo".
    >
    > Steve



    Uh , what is this all about.
    Have I missed another meeting. ?

    I have always used
    <img src="blah.jpg">

    And the validators never question it.


    I know about the alt & title thing but when did this get changed ?????


    Just want to know.
    but on my way over to WC3 just to try to find out for myself

    Gypsy
    Gypsy, Jan 13, 2004
    #3
  4. Gypsy wrote:

    > Uh , what is this all about.
    > Have I missed another meeting. ?
    >
    > I have always used
    > <img src="blah.jpg">
    >
    > And the validators never question it.


    alt has been a required attribute since HTML 4.0. It was optional in HTML
    3.2

    --
    David Dorward <http://dorward.me.uk/>
    David Dorward, Jan 13, 2004
    #4
  5. Richard

    Steve Pugh Guest

    "Gypsy" <> wrote:
    >"Steve Pugh" <> wrote:
    >> "Richard" <anonymous@127.000> wrote:
    >>
    >> >I have <img name="photo.jpg" src="tree.jpg">
    >> >W3 says, "name" is not an attribute.

    >
    >> Let me guess. Based on your other pages you're using a HTML 4.0
    >> Doctype. In HTML 4.0 name was not an allowed attribute of <img>. This
    >> was revised in HTML 4.01.
    >>
    >> So, either use id and make some small changes to your code (and accept
    >> that the JavaScript will no longer work in some rather old browsers)
    >> or change your doctype to HTML 4.01 and carry on using name.

    >
    >Uh , what is this all about.


    It's about adding a name or id attribute to the <img> element in order
    to reference that image from JavaScript.

    >I have always used
    ><img src="blah.jpg">
    >
    >And the validators never question it.


    It should have, as alt is mandatory in any halfway recent version of
    HTML.

    >I know about the alt & title thing but when did this get changed ?????


    It hasn't been changed for several years. Neither name nor id have
    nothing to do with alt or title.

    Steve

    --
    "My theories appal you, my heresies outrage you,
    I never answer letters and you don't like my tie." - The Doctor

    Steve Pugh <> <http://steve.pugh.net/>
    Steve Pugh, Jan 13, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul K

    Trying to understand...

    Paul K, Nov 19, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    338
    Paul K
    Nov 19, 2003
  2. =?Utf-8?B?QmlsbCBCb3Jn?=

    Trying to understand ticket/cookie expiration

    =?Utf-8?B?QmlsbCBCb3Jn?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    346
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Oct 8, 2004
  3. jim

    trying to understand postback

    jim, Nov 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    361
    =?Utf-8?B?Sm9lbCBDYWRl?=
    Nov 22, 2004
  4. elektrophyte

    Trying to understand Tomcat logging

    elektrophyte, Oct 5, 2005, in forum: Java
    Replies:
    0
    Views:
    1,162
    elektrophyte
    Oct 5, 2005
  5. Jimi Hullegård

    Re: Trying to understand Tomcat logging

    Jimi Hullegård, Oct 6, 2005, in forum: Java
    Replies:
    0
    Views:
    410
    Jimi Hullegård
    Oct 6, 2005
Loading...

Share This Page