Thread: w3c validation?
View Single Post
  #14   Spotlight this post!  
Unread 01-09-2003, 19:31
jonathan lall's Avatar
jonathan lall jonathan lall is offline
Registered User
FRC #2505 (The Electric Sheep; FRC #0188 alumnus)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Toronto, Canada
Posts: 547
jonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond reputejonathan lall has a reputation beyond repute
Send a message via MSN to jonathan lall
Time for an example: I have a form, which I will call "contact". It sends an email to me containing a user's name through PHP or Perl or whatever.

Code:
<form id="contact" method="post" action="emailer.cgi">
    <label for="formname">Name</label>
    <input type="text" name="name" id="formname" size="20" />
</form>
In this scenario, the id attributes allow for any DOM (Document Object Model) script or stylesheet to apply rules to a specific element. The id attribute in the input element is purely semantic and denotes that the label applies to it (see its for attribute). The name attribute in that same input is in this case there so that the CGI script knows what it's getting and so the browser knows what its inputting. If, for example, I typed in my name before, in another "name" form, my browser might see that I'm typing "Jo..." in the "name" field and offer to autocomplete it for me, because it knows my name is Jonathan. Good browser. You'll note also that this validates.

By the way, I wasn't meaning to refer to you when I said that, "I think a lot of people use XHTML just because it's new and they think they are somehow writing better code. Really though, the X doesn't make you 1337 ." Just to clear that up. W3Schools did it because they could, and because they knew it would have to be done eventually if they were going to preach about XHTML. I believe that page states more about how they did it than anything. I've read it before, but couldn't find it; I think they used HTML Tidy, but they might've done it by hand, I don't remember.

Edit:
Hooray for typos! I also haven't been clear. I should point out that name can be looked upon as being a replacement for id, and in some specs is deprecated for that exact reason, but it is also absolutely required in certain elements, like form and meta for example. One should never use id instead in these cases. My example is one of the only truly kosher ways to put name in, as forms have always behaved in this manner. Also, one could also use name and id as seperate identifiers for a script should the need arise.
__________________


Last edited by jonathan lall : 01-09-2003 at 21:57.