From the course: HTML & CSS: Creating Forms

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Placeholder attribute

Placeholder attribute - HTML Tutorial

From the course: HTML & CSS: Creating Forms

Start my 1-month free trial

Placeholder attribute

- [Narrator] A placeholder is a pseudo-element that allows you to display text inside a form field and disappears once the user has focus in the field. It's meant to give the user a hint as to what should go in the field. This is an example. Here the placeholder lets the user know that the format of email@example.com is expected in that field. In the code, you can see the placeholder attribute on line 22. It's just "placeholder=" and then whatever text you wish to display. By default, the placeholder appears as gray text. The placeholder can be used on any fill-and-type input field, except for those that already have their own placeholder text, like date or time. The placeholder doesn't need to match the rules for the input element. For example, the zip code placeholder that you see here on this form has a word, even though there's a pattern restricting the field to digits. Although placeholder text is very popular on websites lately, there are several accessibility and usability…

Contents