HTML | value Attribute Last Updated : 30 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The value attribute in HTML is used to specify the value of the element with which it is used. It has different meaning for different HTML elements. Usage: It can be used with the following elements: <input>, <button>, <meter>, <li>, <option>, <progress>, and <param>, <output>. <input>: When the value attribute is present, it specifies the initial value of the input element. It has a different meaning for different input type: When present in "button", "reset" and "submit" it specifies the text on the button. When present in "text", "password" and "hidden" it specifies the initial value of the input field. When present in "checkbox", "radio" and "image" it specifies the value associated with the input. Syntax: <input value = "value"> Example-1: html <!DOCTYPE html> <html> <head> <title>HTML value Attribute</title> </head> <body style = "text-align:center"> <h1 style = "color:green;"> GeeksforGeeks </h1> <h2> HTML value Attribute </h2> Input: <input type = "text" value = "GeeksforGeeks"> </body> </html> Output: Example-2: html <!DOCTYPE html> <html> <head> <title>HTML value Attribute</title> </head> <body style = "text-align:center"> <h1 style = "color:green;"> GeeksforGeeks </h1> <h2> HTML value Attribute </h2> <input type = "button" value = "Click me!"> </body> </html> Output: <button>: When the value attribute is present, it specifies the initial value of the button element. Syntax: <button value = "value"> Example: html <!DOCTYPE html> <html> <head> <title>HTML value Attribute</title> </head> <body style = "text-align:center"> <h1 style = "color:green;"> GeeksforGeeks </h1> <h2> HTML value Attribute </h2> <button id="btn" value="GeeksforGeeks" onclick="geek()"> Click me!</button> <p id="g"></p> <script> function geek() { var x = document.getElementById("btn").value; document.getElementById("g").innerHTML = "Welcome to " + x; } </script> </body> </html> Output: Before clicking the button: After clicking the button: <meter>: It specifies the current value of the gauge. The value must be between min and max attribute. Syntax: <meter value = "value"> Example: html <!DOCTYPE html> <html> <head> <title>HTML value Attribute</title> </head> <body style = "text-align:center"> <h1 style = "color:green;"> GeeksforGeeks </h1> <h2> HTML value Attribute </h2> <p>Health: <meter min="0" low="40" high="90" max="100" value="60"></meter></p> </body> </html> Output: <li>: When the value attribute is present, it specifies the initial value of the list item. It is only applicable on the ordered list. Syntax: <li value = "number">list item </li> number: specifies the value of the list item. Example: html <!DOCTYPE html> <html> <head> <title>HTML value Attribute</title> </head> <body > <h1 style = "color: green;"> GeeksforGeeks </h1> <h2> HTML value Attribute </h2> <p>Sorting Algorithms</p> <ol> <li value="50">Merge sort</li> <li>Quick sort</li> <li>Insertion sort</li> </ol> </body> </html> Output: <option>: When the value attribute is present, it specifies the value of the option element. Syntax: <option value = "value"></option> Example: html <!DOCTYPE html> <html> <head> <title>HTML value Attribute</title> </head> <body style = "text-align:center"> <h1 style = "color: green;"> GeeksforGeeks </h1> <h2> HTML value Attribute </h2> Sorting Algorithms: <select id="opt"> <option value="quick">Quick sort</option> <option value="merge">Merge sort</option> <option value="insertion">Insertion sort</option> </select> <button type="button" onclick="geek()">Click me!</button> <p id = "p"></p> <script> function geek() { var x = document.getElementById("opt").selectedIndex; var y = document.getElementsByTagName("option")[x].value; document.getElementById("p").innerHTML = "The selected option has value equals " + y + "."; } </script> </body> </html> Output: Before clicking the button: After clicking the button: <progress>: When the value attribute is present, it specifies the value of the progress element. Syntax: <progress value = "number"></progress> number specifies the initial value of the progress element. Example: html <!DOCTYPE html> <html> <head> <title>HTML value Attribute</title> </head> <body style = "text-align:center"> <h1 style = "color: green;"> GeeksforGeeks </h1> <h2> HTML value Attribute </h2> Progress: <progress value="65" max="100"> </progress> </body> </html> Output: Supported Browsers: The browser supported by value attribute in progress element are listed below: Google Chrome Internet Explorer Firefox Opera Safari Comment More infoAdvertise with us Next Article HTML action Attribute V Vishal Chaudhary 2 Follow Improve Article Tags : Web Technologies HTML HTML-Attributes Similar Reads HTML accept Attribute HTML accept Attribute specifies the type of file that the server accepts. This attribute can be used with <input> element only. This attribute is not used for validation tools because file uploads should be validated on the Server.Syntax:<input accept = "file_extension"> Note: This attri 3 min read HTML accept-charset Attribute The accept-charset attribute is used to define the character encoding and is used for form submission. The default value of the accept-charset attribute is "UNKNOWN" string which indicates the encoding equals to the encoding of the document containing the <form> element. Syntax:<form accept 2 min read HTML accesskey Attribute The HTML accesskey attribute defines a keyboard shortcut to activate or focus an element.It assigns a keyboard key combination to trigger an element (like a link or button).Browser support and specific key combinations vary (e.g., Alt + key on Windows, Ctrl + key on macOS).Use it sparingly and provi 3 min read HTML action Attribute The HTML action attribute is used to specify where the form data should be sent on submission. It allows the browser to send the data to the specified location, enabling server-side scripts to process the data and generate a response.Note: It can be used in the <form> element. Syntax:<form 3 min read HTML align Attribute In HTML, the align attribute is used to control the alignment of elements on a webpage. Whether it's for text, images, or tables, the align attribute helps to position content in relation to its surrounding elements.Syntax<element_name align="left | right | center | justify">Attribute ValuesAt 4 min read HTML alt attribute The alt attribute in HTML provides alternative text for images, aiding accessibility and providing context for screen readers.Syntax:<img src=" " alt=" " >HTML<html> <body> <h1>GeeksforGeeks Logo</h1> <img src="https://media.geeksforgeeks.org/wp-content/uploads/20190 3 min read HTML async Attribute The HTML <script> async attribute is used to load and execute external scripts without blocking the rest of the page from loading. This speeds up page load times. It only works with external scripts (when the src attribute is present).Syntax:<script src="path-to-script.js" async></scr 3 min read HTML autocomplete Attribute The HTML autocomplete Attribute is used to specify whether the input field autocompleted would be on or off. When the autocomplete attribute is set to on the browser will automatically complete the values based on what the user entered before. It works with input fields such as text, search, URL, em 3 min read HTML autoplay Attribute The HTML autoplay Attribute, a boolean attribute, enables audio or video elements to start playing automatically when the page loads, providing seamless playback without interruption.Syntax: <element autoplay> Supported ElementsIt can be used with <audio> and <video> elements. Elem 2 min read HTML autofocus Attribute The HTML autofocus attribute is a powerful tool that enhances user experience by automatically setting the focus to a specific element when a webpage loads. Syntax<input type="text" autofocus> Note: This attribute is boolean, meaning it can either be present or absent.Supported TagsElementPurp 2 min read Like