The HTML selected attribute define that an option should be already selected when the web page loads.
Syntax
Following is the syntax −
<option selected></option>
Let us see an example of HTML selected Attribute −
Example
<!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; background-color: #8BC6EC; background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%); text-align: center; } </style> <body> <h1>HTML selected Demo</h1> <p>Select your favourite subject:</p> <select> <option value="Physics">Physics</option> <option value="Chemistry">Chemistry</option> <option value="Biology" selected>Biology</option> </select> </body> </html>