Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 997
daCoda Avatar asked Sep 10 '13 01:09

daCoda


2 Answers

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.

like image 61
Claudio Redi Avatar answered Oct 04 '22 15:10

Claudio Redi


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.

like image 34
Joseph Silber Avatar answered Oct 04 '22 14:10

Joseph Silber