CSS Portal

HTML value Attribute

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The HTML value attribute is used to define the initial or default value of an input element such as <input>, <button>, <option>, <meter>, or <progress>. It specifies the value that will be displayed or submitted when the form is initially loaded or reset.

For example, in an <input> element of type "text" or "number", the value attribute defines the initial text displayed in the input field. Similarly, in a <button> element, it sets the initial label displayed on the button. In <option> elements within a <select> element, the value attribute specifies the value that will be submitted if that option is selected.

Here's a basic example of its usage:

<input type="text" value="Default Text">

In this example, the initial value of the text input field will be "Default Text".

It's important to note that while the value attribute sets the initial value, users can still change this value interactively in the browser. If you want to prevent user modification, you might consider using the readonly attribute in conjunction with value, or setting the disabled attribute if user input should be entirely disabled.

Syntax

<tagname value="text">

Values

  • textAn alphanumeric string.

Example

<form action="formscript.php" method="post">
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" value="John Doe">
<br><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" value="john.doe@example.com">
<br><br>
<input type="submit" value="Submit">
</form>

Browser Support

The following information will show you the current browser support for the HTML value attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.

This attribute is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 30th March 2024

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!