HTML option value Attribute


The HTML option value attribute define the value of the option HTML element which is to be sent on a server when the form is submitted in an HTML document.

Syntax

Following is the syntax −

<option value=”text”></option>

Let us see an example of HTML option value Attribute −

Example

Live Demo

<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      height: 100vh;
      background-color: #8BC6EC;
      background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
      text-align: center;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
      margin: 1rem auto;
   }
</style>
<body>
<h1>HTML optimum Attribute Demo</h1>
<p>Select your favourite subject:</p>
<form method="post" action="">
<select>
<option value="Physics">Physics</option>
<option value="Chemistry">Chemistry</option>
<option value="Biology">Biology</option>
</select>
<input type="submit" value="Submit" class="btn">
</form>
</body>
</html>

Output

Updated on: 17-Feb-2021

303 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements