HTML value attribute
value
The purpose of the HTML value attribute is to specify the current value for an input type. For those elements that can display their values (such as text fields), they will display this value onscreen. Otherwise, the values are all available as form values when submitted.
Supported elements
HTML value attribute supports button, input, option, param elements.
Syntax
<ElementName value="value" >.....</ElementName>
Where ElementName is any supported element.
Type of value
Character Data.
Default value
There is no default value of HTML value attribute.Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.
Example of HTML value attribute
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML value attribute</title>
</head>
<body>
<form name="user_info" action="action_get.php" method="get">
Name : <input type="text" name="name"><br>
email : <input type="text" name="email"><br>
<label>Select your favorite sports</label>
<select size="2">
<option value="Soccer">Soccer</option>
<option value="Hockey">Hockey</option>
<option value="Tennis">Tennis</option>
<option value="Golf">Golf</option>
</select><br>
<label>Why do you like this sport? </label> <br>
<textarea name="description" rows="10" cols="5"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML value attribute
Previous: HTML valign attribute
Next: HTML valuetype attribute
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/html/attributes/html-value-attribute.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics