Placeholder and Data-placeholder ?

Tram Ho

Placehodel: Place data (according to the dictionary).

The placeholder property specifies a short hint describing the expected value of the input field (for example, a sample value or a short description of the expected format).

A short hint is displayed in the input field before the user enters a value.

1. Placeholder uses

Step 1: Add the placeholder attribute on the input . tag

Syntax:

Attribute value:

ValueDescribe
TextSpecify a short hint describing the expected value of the input field

Step 2: Add on CSS

2 . Difference between placeholder and data-placeholder

  • The placeholder attribute is a standard HTML5 attribute
  • data-placeholder is just data- HTML5 attribute used by some javascript plugins. Data is the generic data attached to the element.

Try the example below to see the difference:

Share the news now

Source : Viblo