Is using name attribute deprecated in html5?

Should I use the name attribure only for form controls? Is it deprecated today on html5?

I noticed similar questions are outdated, so I'm a little confused.


After a couple minutes research, it seems that using <a name=""> is depreciated - which means you shouldn't use it for your anchor tags.

On forms you should still use name="" to label your form controls - AngularJS requires you to use name="" if you ever want to use validation.

Some more information Here and Here.


Should I use the name attribute only for form controls?

No. It is only on <a> elements that it is obsolete (and replaced with id on any element).

The attributes index in the HTML5 spec shows where it should still be used.

Some uses of it which were never standard should be replaced with class .

Is it deprecated today on html5?

HTML5 doesn't use the term "deprecated". It describes it as obsolete.


I checked Mozilla Developer Network (MDN) and found this:

name

<button>, <form>, <fieldset>, <iframe>, <input>, <keygen>, <object>, <output>, <select>, <textarea>, <map>, <meta>, <param>

Name of the element. For example used by the server to identify the fields in form submits.

So you should use this attribute only on these elements. Any other element with name attr is not correct. For more info about what attributes exists and where/who/why to use it check the full documentation:

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes

链接地址: http://www.djcxy.com/p/88060.html

上一篇: 为隐藏的输入标签添加值并提交表单

下一篇: 是否使用HTML5中的名称属性弃用?