img name or ID

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TheKeith

    img name or ID

    I heard that the name attribute is deprecated in html 4.01 strict. Is it
    recommended that you use the ID attribute for images along with the
    getElementById method instead of the old way? Thanks.


  • Vicomte De Valmont

    #2
    Re: img name or ID

    I don't know if it is deprecated, it surprises me a bit for there exist a
    global collection
    document.images
    That collection is addressed by numerical indexes or by NAME properties:
    document.images["mygifName"].src
    this is why if it has been deprectaed it would surprise me. yet everything
    is possible...!

    Yet, of course getElementById requires an ID="something" .
    Of course, you can use both name= and id= in an image - the name to exploit
    the document.images collection, the id for getElementById or, let's say,
    dhtml
    ciao
    Alberto Vallini


    "TheKeith" <no@spam.com> ha scritto nel messaggio
    news:JYidnfGOka EhsgGiRVn-tg@giganews.com ...[color=blue]
    > I heard that the name attribute is deprecated in html 4.01 strict. Is it
    > recommended that you use the ID attribute for images along with the
    > getElementById method instead of the old way? Thanks.
    >
    >[/color]


    Comment

    • HikksNotAtHome

      #3
      Re: img name or ID

      >From: "TheKeith" no@spam.com
      [color=blue]
      >I heard that the name attribute is deprecated in html 4.01 strict. Is it
      >recommended that you use the ID attribute for images along with the
      >getElementBy Id method instead of the old way? Thanks.[/color]

      I just validated a page, with html4.01 strict, that has name attributes in the
      img tags and it validated fine. So I doubt that its been deprecated. If it has,
      then the validator at w3c is wrong.


      --
      Randy

      Comment

      • TheKeith

        #4
        Re: img name or ID


        "HikksNotAtHome " <hikksnotathome @aol.com> wrote in message
        news:2003102615 4742.28070.0000 0204@mb-m27.aol.com...[color=blue][color=green]
        > >From: "TheKeith" no@spam.com[/color]
        >[color=green]
        > >I heard that the name attribute is deprecated in html 4.01 strict. Is it
        > >recommended that you use the ID attribute for images along with the
        > >getElementBy Id method instead of the old way? Thanks.[/color]
        >
        > I just validated a page, with html4.01 strict, that has name attributes in[/color]
        the[color=blue]
        > img tags and it validated fine. So I doubt that its been deprecated. If it[/color]
        has,[color=blue]
        > then the validator at w3c is wrong.[/color]


        Yeah I validated an image map where the image has a name attribute in it. I
        guess I'm wrong about this one--can't remember where I heard it.


        Comment

        • Lasse Reichstein Nielsen

          #5
          Re: img name or ID

          "TheKeith" <no@spam.com> writes:
          [color=blue]
          > I heard that the name attribute is deprecated in html 4.01 strict.[/color]

          Some uses of the name attribute are deprecated in HTML 4.01. That
          means that they are removed from HTML 4.01 Strict, and not just
          deprecated.
          [color=blue]
          > Is it recommended that you use the ID attribute for images along
          > with the getElementById method instead of the old way?[/color]

          In HTML 4.01 Strict, if you need to name an element, other than a form
          control, you should use the id attribute. It is the only available
          attribute.

          You can use either document.getEle mentsById or document.images .namedItem
          to access an image in W3C DOM 2 HTML. In ECMAScript, using square brackets
          is equivalent to using the namedItem method on collections.

          /L
          --
          Lasse Reichstein Nielsen - lrn@hotpop.com
          DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
          'Faith without judgement merely degrades the spirit divine.'

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: img name or ID

            TheKeith wrote:
            [color=blue]
            > I heard that the name attribute is deprecated in html 4.01 strict.[/color]

            The `name' attribute for the `img' element is _not_ deprecated:

            http://www.w3.org/TR/html4/index/attributes.html#n (no `D' there at `IMG'!)
            [color=blue]
            > Is it recommended that you use the ID attribute for images along
            > with the getElementById method instead of the old way?[/color]

            That's what the HTML 4.01 Specification recommends but you need to
            reconsider that, depending on your target group. If you don't want
            to exclude users of UAs not capable of the W3C-DOM like Netscape 4.x,
            use the `name' attribute anyway since there is no other way than the
            so-called "DOM Level 0"'s document.images[...] collection to access
            images.


            PointedEars

            Comment

            • Lasse Reichstein Nielsen

              #7
              Re: img name or ID

              Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:
              [color=blue]
              > the so-called "DOM Level 0"'s document.images[...] collection to access
              > images.[/color]

              The document.images collection is actually official DOM 2.
              <URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-90379117>

              /L
              --
              Lasse Reichstein Nielsen - lrn@hotpop.com
              DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
              'Faith without judgement merely degrades the spirit divine.'

              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: img name or ID

                Lasse Reichstein Nielsen wrote:
                [color=blue]
                > Thomas 'PointedEars' Lahn <PointedEars@we b.de> writes:[color=green]
                >> the so-called "DOM Level 0"'s document.images[...] collection to access
                >> images.[/color]
                >
                > The document.images collection is actually official DOM 2.
                > <URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-90379117>[/color]

                Ah, thx :)


                \V/ Live long and prosper

                PointedEars

                Comment

                • Dom Leonard

                  #9
                  Re: img name or ID

                  TheKeith wrote:
                  [color=blue]
                  > I heard that the name attribute is deprecated in html 4.01 strict.[/color]

                  No. The attribute index in the recommendation from



                  only shows the name attribute of the APPLET tag as being deprecated, but
                  this follows from the APPLET tag being deprecated. A search through
                  the DTD itself shows name attributes on various element types, including
                  IMG.

                  Is it[color=blue]
                  > recommended that you use the ID attribute for images along with the
                  > getElementById method instead of the old way?[/color]

                  Yes and not necessarily.

                  It recommends to use id on image elements to identify them, but allows
                  giving them a name attribute (with the exact same value as any id
                  attribute provided) for backwards compatability.

                  The DOM2 HTML recommendation describes the document.images collection
                  without deprecation. It notes for backwards compatability the collection
                  excludes images included in the document using OBJECT tags, and
                  recommends using getElementsByTa gName instead of document.images to
                  "find the images in the document". In the absence of deprecation, I take
                  this to imply "when the presence of images resulting from OBJECT tag
                  usage may be at issue".

                  Using getElementById to find images is perfectly acceptable.

                  --

                  Dom




                  Comment

                  • DU

                    #10
                    Re: img name or ID

                    TheKeith wrote:[color=blue]
                    > I heard that the name attribute is deprecated in html 4.01 strict. Is it
                    > recommended that you use the ID attribute for images along with the
                    > getElementById method instead of the old way? Thanks.
                    >
                    >[/color]

                    I recommend you only use the id attribute for <img> for 2 reasons:
                    - id is unique when name attribute is not
                    - if you ever want to convert your HTML 4.01 page to XHTML, then you're
                    already a step closer since "XHTML 1.0 has deprecated the name attribute
                    of the a, applet, form, frame, iframe, img, and map elements, and it
                    will be removed from XHTML in subsequent versions."


                    DU
                    --
                    Javascript and Browser bugs:

                    - Resources, help and tips for Netscape 7.x users and Composer
                    - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


                    Comment

                    • DU

                      #11
                      Re: img name or ID

                      DU wrote:

                      Even the HTML 4.01 recommendation also recommends, prefers id attribute
                      over name attribute for <img>: "This attribute (name) has been included
                      for backwards compatibility. Applications should use the id attribute to
                      identify elements."


                      DU
                      --
                      Javascript and Browser bugs:

                      - Resources, help and tips for Netscape 7.x users and Composer
                      - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


                      Comment

                      • TheKeith

                        #12
                        Re: img name or ID


                        "DU" <drunclear@ho t-R-E-M-O-V-E-mail.com> wrote in message
                        news:bni5pn$no6 $1@news.eusc.in ter.net...[color=blue]
                        > DU wrote:
                        >
                        > Even the HTML 4.01 recommendation also recommends, prefers id attribute
                        > over name attribute for <img>: "This attribute (name) has been included
                        > for backwards compatibility. Applications should use the id attribute to
                        > identify elements."
                        > http://www.w3.org/TR/html401/struct/...#adef-name-IMG
                        >[/color]

                        I'll use the ID attribute from now on especially since I'm learning--there's
                        no point in learning an old way of doing something. I might as well keep
                        everything uniform by using ID for everything.


                        Comment

                        • Vicomte De Valmont

                          #13
                          Re: img name or ID

                          ciao
                          uhm why not using both? I mean an old way of doing soemthing doesn't age:
                          the document.images collection is an useful tool: it grants you the option
                          to loop throughout ALL the available images with an array already arranged.
                          otherwise you'd have to arrange it yourself, either patching up a collection
                          by repeatedly calling in document.getEle mentById('image 101') or by
                          document.getEle mentsByTagName( "A")
                          the former is highly unpractical, the second is much slower than just using
                          an object which is already within the built in arrays of a loaded document.
                          It is not an issue of purist vs moderns: it is that I'm suggesting: use
                          both - dismissing the name just because they ADDED the id feature doesn't
                          mean you have to give up the possibility to scan all your images with an
                          alrerady available collection. Again, name= is NOT deprecated.
                          Of course, feel free to dismiss my suggestion, but please: it is NOT a
                          suggestion of "old school" vs "new school": it is the suggestion that
                          everybody with javascript expereince would be likely to lend to you.
                          Of course, eventually do as you prefer. yet using two weapons instead than
                          one is better - we have not given up the rifle because we have the scuds.
                          ciao

                          Alberto


                          "TheKeith" <no@spam.com> ha scritto nel messaggio
                          news:DJWdnUQbLM EcBgGiRVn-jw@giganews.com ...[color=blue]
                          >
                          > "DU" <drunclear@ho t-R-E-M-O-V-E-mail.com> wrote in message
                          > news:bni5pn$no6 $1@news.eusc.in ter.net...[color=green]
                          > > DU wrote:
                          > >
                          > > Even the HTML 4.01 recommendation also recommends, prefers id attribute
                          > > over name attribute for <img>: "This attribute (name) has been included
                          > > for backwards compatibility. Applications should use the id attribute to
                          > > identify elements."
                          > > http://www.w3.org/TR/html401/struct/...#adef-name-IMG
                          > >[/color]
                          >
                          > I'll use the ID attribute from now on especially since I'm[/color]
                          learning--there's[color=blue]
                          > no point in learning an old way of doing something. I might as well keep
                          > everything uniform by using ID for everything.
                          >
                          >[/color]


                          Comment

                          • cwdjr

                            #14
                            Re: img name or ID

                            I converted several pages from xhtml 1.0 strict to xhtml 1.1 just
                            after the W3C validator included xhtml 1.1. There was little change
                            required on most pages. And then I came to a set of linked pages that
                            used "name". The validator found an error for every name I used, and I
                            had to convert about 50 names to id. I will let the W3C speak for
                            itself in the following quote.:"This Appendix describes the
                            differences between XHTML 1.1 and XHTML 1.0 Strict. XHTML 1.1
                            represents a departure from both HTML 4 and XHTML 1.0. Most
                            significant is the removal of features that were deprecated. In
                            general, the strategy is to define a markup language that is rich in
                            structural functionality, but that relies upon style sheets for
                            presentation.Th e differences can be summarized as follows:On every
                            element, the lang attribute has been removed in favor of the xml:lang
                            attribute (as defined in [XHTMLMOD]).On the a and map elements, the
                            name attribute has been removed in favor of the id attribute (as
                            defined in [XHTMLMOD]).The "ruby" collection of elements has been
                            added (as defined in [RUBY])."

                            Comment

                            • Keith Bowes

                              #15
                              Re: img name or ID

                              TheKeith wrote:[color=blue]
                              > I heard that the name attribute is deprecated in html 4.01 strict.[/color]

                              It's been deprecated in XHTML 1.0 Strict, and completely removed from
                              XHTML 1.1. But it's still standard in HTML 4.01.


                              Comment

                              Working...