Placeholder and data-placeholder, in HTML

What is the difference between the two?

placeholder and data-placeholder?

Both seem to give the same results .

<select data-placeholder="Enter name"> <select placeholder="Enter name"> 

What's the difference?

(Which one is stronger?)

+8
html placeholder
source share
2 answers

The placeholder attribute is the standard HTML5 attribute, and the data-placeholder is only the data- HTML5 attribute used by some javascript plugin.

Without an external js plugin, the data-placeholder does nothing while the placeholder works with the only requirement for HTML5 support in the client’s browser.

+12
source share

They cannot give the same results. placeholder is part of the HTML5 specification to display placeholder text in a field before something is typed, and data-* is the general data attached to the element.

Perhaps you have a JavaScript polyfill or something on a page that uses a data-placeholder .

+5
source share

All Articles