www.webdeveloper.com
Results 1 to 15 of 15

Thread: XHTML does not like "Name" attribute

  1. #1
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    17

    XHTML does not like "Name" attribute

    I'm trying to validate a web page so that it's xhtml strict. XHTML doesn't use the "Name" attribute in an IMG tag. Am I unable to declare a "name" attribute in an IMG tag?

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Nope, no "name". But why on earth would you want to give an image a name anyway? And, more importantly, why are you bothering with XHTML? HTML 4.01 Strict is much better for most all applications.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    17
    hmm.. i'm working on a site and entering it into a content management system which requires the pages to be XHTML. as for the NAME attribute in the IMG tag, not sure what it's used for. I didn't write any of the HTML itsefl. This is what I have to work with.

    this the IMG i'm reffering to
    <img src="/images/tab_stu_e.gif" alt="Students" name="stutab" width="89" height="23" style="border-width: 0px" id="stutab" />

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Just rid yourself of that troublesome "name" attriute.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    I suspect "id" would be more appropriate than "name", though I doubt either is needed unless you have some Javascripting going on that needs it to reference that element for some reason.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #6
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    The only tags that need names in XHTML are radio buttons. All other tags should use ids instead.
    Stephen

  7. #7
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    Well, that is true about the radios even if your form ain't submitting to anywhere.
    But don't all your other INPUT fields within your FORM need NAMEs too in the case of forms submitting to somewhere? I'm no good with XHTML, so this is an actual question.

  8. #8
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    In XHTML 1.0 Strict META elements require "name" or "htp-equiv" attributes. The following elements can take "name" attributes: A, OBJECT, PARAM, MAP, INPUT, SELECT, TEXTAREA, BUTTON. In XHTML 1.0 transtional add the IMG element.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  9. #9
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    Wow, what a way to cover all the details! Thanks.

  10. #10
    Join Date
    Aug 2005
    Location
    Northampton, UK.
    Posts
    421
    "i use xhtml and html, i just tend to use id (exept for in the meta tag) is there a problem with that(less professional or sumtin).

  11. #11
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    The "id" attribute is quite fine but some say it is better to use the "name" attribute with FORM controls. Don't get me started about XHTML.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  12. #12
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    You can use name or id with form controls. The only form controls where you have to use name are radio buttons.
    Stephen

  13. #13
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    From the HTML 4.01 Specification:
    A control's "control name" is given by its name attribute.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  14. #14
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    17
    thx for all the help. i ended up just taking the name attribute out compeletely. it had no effect on the functionality of the page.

  15. #15
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    You can use name or id with form controls.
    There are definitely situations where only using id will cause problems. I always use both because I never know when we'll have to go back and add validations.
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles