04-17-2011, 04:37 PM
Thanks a lot
04-18-2011, 12:13 AM
The name attribute is used to mark an anchor or a bookmark in a page. It's used with <A> and <map> tags, but it my be on it's way out (??) The ID is a css selector use to id a unique html element.
That's probably not an official definition, but that's how I see it.
04-18-2011, 01:32 AM
The name attribute is actually deprecated for all elements other than form controls (input, select, textarea) and should therefore not be used anymore (except for the aforementioned ones). Technically, ID and name have the same purpose, they uniquely designate an element. However, unlike the ID attribute, the name attribute can’t be referenced in CSS (except with more complicated attribute selectors). PHP is using the name attribute of form controls (not the form element itself, however). With JS there are designated ways to address form controls so no need to use the name attribute. Above all, you can also address the ID with JS. For internal page anchors the ID attribute should be used, as name is deprecated.
04-18-2011, 02:16 AM
yep, agree with vipstephan.
A lot of people still use the name attribute in a form tag which is deprecated in (x)html.
For example, this html will not pass the w3c validator.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<form name="myform" action="qwert.php" method="post">
<input type="text" name="txtUsername" >