placeholder vs. data-placeholder, in HTML

妖精的绣舞 提交于 2019-12-06 22:08:05

问题


What's the difference between the two?

placeholder vs. data-placeholder?

They both seem to produce the same results.

<select data-placeholder="Enter name">

<select placeholder="Enter name">

What's the difference?

(Which one's stronger?)


回答1:


Attribute placeholder is a standard HTML5 attribute and data-placeholder is just data- HTML5 attribute used by some javascript plugin.

Without the external js plugin, data-placeholder does nothing while placeholder works with the only requirement of having HTML5 support on client browser.




回答2:


They can't possibly produce the same results. placeholder is part of the HTML5 spec to show placeholder text in the field before anything is typed, while data-* is just generic data attached to the element.

You might have some JavaScript polyfill or something on the page that uses data-placeholder.



来源:https://stackoverflow.com/questions/18709580/placeholder-vs-data-placeholder-in-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!