The name and id Attributes

 <  Day Day Up  >  


The name and id Attributes

Before presenting all the form fields, it's important to understand the issues surrounding the name and id attributes. Both of these attributes are used to name the <form> tag itself and the individual fields within it. Traditionally, only the name attribute was supported and was used both for the name-value pairs submitted to the server as well as for scripting. With HTML 4 and XHTML, the id attribute is also used. The main duty of id is for CSS and JavaScript usage, while name is used for both server-side programming and JavaScript. Given the overlap, page authors often set name and id to the same value where possible. In most cases, they are exactly the same but there are some troubling inconsistencies. For example, for fields such as check boxes and radio buttons , the values may actually have to be different. This important difference will be presented in detail when those fields are discussed.

Note  

Interestingly enough, under the strict variant of XHTML, the attribute name on the form element is deprecated, but current browser support suggests to ignore the validation error as the form may not be scriptable under some browsers without name .



 <  Day Day Up  >  


HTML & XHTML
HTML & XHTML: The Complete Reference (Osborne Complete Reference Series)
ISBN: 007222942X
EAN: 2147483647
Year: 2003
Pages: 252
Authors: Thomas Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net