Languages
[Edit]
EN

HTML - set text input initial value

0 points
Created by:
Isaiah89
361

In this article, we would like to show you how to set text input initial value in HTML.

Quick solution:

<input type="text" name="username" value="Example-username" />

 

Practical example

In this example, we use input element's value attribute to set its default value.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<body>
  <form>
    <label>
      <span>Username:</span>
      <input type="text" name="username" value="Example-username" />
    </label>
  </form>
</body>
</html>

Note:

When you use input reset, it will restore input to the default value from the value attribute.

References

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join