CSS Portal

HTML value Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
value
HTML AttributeThis attribute is supported by all modern browsers.
Updated 30th March 2024

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.

Applies To

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>
Open in editor

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
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee