
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to add the value of the element in HTML?
This article will teach you how to add the value of the element in HTML. We have a basic idea about the value attribute in HTML and the situations where we use the value attribute Let’s look forward to a better understanding of the HTML value attribute.
In HTML, the value property is used to describe the value of the element that it is used with. For various HTML components, it has a varied meaning. Usage− It can be put to use with the <input>, <button>, <meter>, <li>, <option>, <progress>, and <param>, <output> elements. <input> − When the value attribute is present, it indicates what the input element's default value is.
For various types of input, it has a distinct meaning:
It specifies the text on the button when it is present in "button," "reset," and "submit."
It specifies the initial value of the input field when it is present in the "text," "password," and "hidden" values.
When "checkbox," "radio," and "picture" are present, it indicates the value connected to the input.
HTML <button> tag
The clickable button in HTML is defined by the <button> tag. The content is sent using the <button> tag. The <button> tag can contain graphics and text information. Different default types for "button" are used by various browsers.
Example
In the following example we are creating two <button> tag for subjects where one acts as HTML subject button and another one acts as JAVA subject button.
<!DOCTYPE html> <html> <body> <form action="#" method="get"> Choose The Subject: <button name="subject" type="submit" value="HTML">HTML</button> <button name="subject" type="submit" value="java">JAVA</button> </form> </body> </html>
HTML <input> tag
The <input> tag designates a field for user-enterable data. The most significant form element is the <input> element. Depending on the type attribute, the <input> element can be presented in a number of different ways.
Example
Considering the following example, where we are using HTML form with <input> tag with default values
<!DOCTYPE html> <html> <body> <form action="#"> <label for="firstname">FIRST NAME:</label> <input type="text" id="firstname" name="firstname" value="TUTORIALS"><br><br> <label for="lastname">LAST NAME:</label> <input type="text" id="lastname" name="lastname" value="POINT"><br><br> <input type="submit" value="Submit"> </form> </body> </html>
When the above script is run, it will produce an output that includes an input field displaying default values for the first name and last name using the value attribute along with a submit button on the webpage.
<li> HTML element
A list item is defined using the <li> tag. Ordered lists, unordered lists, and menu lists all use the <li> tag. The list items are typically displayed with bullet points in <ul> and <menu>. The list items in <ol> are typically represented by numbers or letters.
Example
Consider the following example we are using the value attribute in the ordered list.
<!DOCTYPE html> <html> <body> <ol> <li value="100">THAR</li> <li>BMW</li> <li>DUCATI</li> <li>BENZ</li> <li>TERRANO</li> <li>CIAZ</li> </ol> </body> </html>
On running the above script, the output window will pop up, displaying the ordered list of different cars used in the script, starting with number 100 as we mentioned value="100" on the webpage.
Using Script
In the following example we are running a script to change the value of textfield.
Example
<!DOCTYPE html> <html> <body> Name: <input type="text" id="mytutorial" value="THOR"> <p>Click To Change Value </p> <button onclick="mytutorial1()">Click</button> <script> function mytutorial1() { document.getElementById("mytutorial").value = "BLACK WIDOW"; } </script> </body> </html>
When the script gets executed, it will generate an output consisting of an input field with a value ="thor" along with a click button. When the user clicks the button, the event gets triggered and changes the input value="black widow" on the webpage.
- Related Articles
- How to add the height of the element in HTML?
- How to add the maximum value to HTML?
- How to add an address element in HTML?
- How to add attributes to an HTML element in jQuery?
- How to add display:none in an HTML element using jQuery?
- How to display a short hint that describes the expected value of the element in HTML?
- How to add a new element to HTML DOM in JavaScript?
- How do we add the maximum number of characters allowed in an element in HTML?
- How to add many Event Handlers to the same element with JavaScript HTML DOM?
- How to add a new value to each element of list in R?
- How to set the name of the element in HTML?
- How to add a unique id for an element in HTML?
- How to add an element horizontally in HTML page using JavaScript?
- How to add a regular expression that an input element's value is checked against in HTML?
- How to add a value to a particular matrix element in R?
