HTML Input - already filled in text

JavaStudent123 picture JavaStudent123 · May 28, 2015 · Viewed 115k times · Source

I was wondering, is there a way to put text into an input field? What i've got now is a placeholder, but that's actually an empty inputfield. So that's not what i'm looking for. I'm looking for an (kind of) placeholder that's actually filled in into the input field, so not "background text"

This is with placeholder:

http://i.stack.imgur.com/NWY3y.png

And this is what i want:

http://i.stack.imgur.com/AfGSy.png

Is there any way to do this?

Thanks in advance!

Answer

user4639281 picture user4639281 · May 28, 2015

The value content attribute gives the default value of the input element.

- http://www.w3.org/TR/html5/forms.html#attr-input-value

To set the default value of an input element, use the value attribute.

<input type="text" value="default value">