daCoda
daCoda

Reputation: 3845

placeholder vs. data-placeholder, in HTML

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?)

Upvotes: 15

Views: 33997

Answers (2)

Claudio Redi
Claudio Redi

Reputation: 68400

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.

Upvotes: 18

Joseph Silber
Joseph Silber

Reputation: 219938

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.

Upvotes: 5

Related Questions