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?
Edit: I'm familiar with the pattern, have used it before, and know what it does, so I'm kind of looking for a more in-depth explanation of what other contexts the attribute can be used in, and how those contexts relate to each other.
<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 attributezap
and elementbar
has attributezap
, 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
forh1
means the same asalign
forh2
), partly similar meanings (e.g.,align
forh1
is similar toalign
fortable
, but not the same). But e.g.type
attribute forol
has really nothing to do withtype
forscript
.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 forapplet
, but only because the element itself has been deprecated. But forform
anda
, 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 toname
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 themeta
element as well as in theiframe
element, if you wish to specify such an element as a “browsing context” to be referred to in atarget
attribute.