I realize that it is used to designate the names of form fields when it comes time for submission to a server. But what about in the context of frames and forms' @target
s?
Can someone give an explanation of what the deal is with the following pattern?
<form target=foo></form
...and then...
<iframe name=foo />
Oh!, and also, is it considered bad practice to use it outside of identifying form fields to the server? I've heard some place that I can't remember that it's deprecated for use in some contexts.
Thanks.
There is no deeper explanation to how some attribute is used for different elements, beyond its definition for each element. If element foo
has attribute zap
and element bar
has attribute zap
, then these attributes share just the name, unless of course they are defined to have the same meaning. The attributes may have completely different meanings and they may take completely different values; it all depends on their definitions.
In practice, the designers of HTML tried to be somewhat consistent here, so that the name of an attribute reflects its meaning. For example, the align
attribute has partly the same meaning for different elements (e.g., align
for h1
means the same as align
for h2
), partly similar meanings (e.g., align
for h1
is similar to align
for table
, but not the same). But e.g. type
attribute for ol
has really nothing to do with type
for script
.
The index of attributes in the HTML 4.01 spec gives an overview of such issues. There you can also see the name
attributes for different elements summarized.
In HTML 4.01, name
has been declared for applet
, but only because the element itself has been deprecated. But for form
and a
, the prose of the spec says: “Note. This attribute has been included for backwards compatibility. Applications should use the id attribute to identify elements.” This, or similar statements, have often been misunderstood as applying to name
elements in general; that would be all wrong, and even absurd.
The name
attribute is needed for form field elements so that they will contribute to the form data, as the contributions are based on his attribute (and the value of the element). It is also essential in one of the two types of the meta
element as well as in the iframe
element, if you wish to specify such an element as a “browsing context” to be referred to in a target
attribute.