What is the difference between the id
and name
attributes? They both seem to serve the same purpose of providing an identifier.
I would lik
Use name
attributes for form controls (such as and
), as that's the identifier used in the
POST
or GET
call that happens on form submission.
Use id
attributes whenever you need to address a particular HTML element with CSS, JavaScript or a fragment identifier. It's possible to look up elements by name, too, but it's simpler and more reliable to look them up by ID.