Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4117940
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:53:50+00:00 2026-05-20T22:53:50+00:00

I remember reading in the spec once that both the id attribute and the

  • 0

I remember reading in the spec once that both the id attribute and the name attribute share the same namespace and have to be unique. Henceforth I’ve always tried to fulfill this requirement in my applications, dreading even to give the same id and name to the same element.

But lately I’ve started working with ASP.NET MVC 3, and it (like PHP) can use the same name attribute on several input controls to form a collection of values at server-side. I tried to look up the relevant section in the spec – but failed to find it. Perhaps I have misunderstood something then, or read the wrong documentation?

How is it then? I want to produce as valid HTML as possible (both 4.01 and 5 in different apps). Can I use this trick without fear? Or would I be violating something and should better stick to unique values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:53:50+00:00Added an answer on May 20, 2026 at 10:53 pm

    The name attribute is only valid on the <form> and form elements (<input>,<textarea> and <select>). It’s used to specify the name to associate with the name/value pair that is submitted on a form post.

    For example:

    <input type="checkbox" name="foo" value="1" />
    

    if checked will submit foo=1. In the DOM you can reference form elements from the form.elements collection by specifying the name as the index. If name is not unique, the collection returns an array of elements rather than the element. Modern DOM’s support looking up form elements by name as:

     document.getElementsByName(nameValue)
    

    note: it always returns an array even if only one element is found.

    id attribute is from the XML world, and is a unique id for any node, not just form elements. Unlike the name attribute it is valid on any HTML node. Also like the name attribute, it must follow the valid identifier rules. The identifier should start with an alpha, and only contain alpha ([a-zA-Z]), numbers, hyphen, underscore and colons (note ASP.NET breaks this rule by starting reserved IDs with a underscore – thus they will always fail an HTML/XML lint – actually some proxies strip them). To find any HTML element by id you use:

    document.getElementById(idvalue)
    

    this only returns one DOM node.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remember reading somewhere that you could make two android apps share the same
I remember reading once that there was a way to embed an image into
I remember reading once that the order of the members of an evaluation is
A long time ago I remember reading that you should always use the smallest
I remember reading something once, but could not find it now while searching, if
I remember reading somewhere that Hadoop's performance deteriorates significantly if the machines it runs
I remember reading a blog post about a group that had taken a branch
I remember reading that static variables declared inside methods is not thread-safe. (See What
I remember reading an article that an average programmer spends 90% of the working
I may be crazy, but I thought I remember reading that OnLoginError produces a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.