HTML Code:
<!DOCTYPE html><!-- Opening tag for declaring the document type -->
<html><!-- Opening tag for the root element of the HTML document -->
<head><!-- Opening tag for the document's header section -->
<meta charset="utf-8"><!-- Metadata tag specifying the character encoding of the document -->
<title>Example of HTML name attribute with form</title><!-- Title of the HTML document -->
</head><!-- Closing tag for the document's header section -->
<body><!-- Opening tag for the document's body section -->
<form name="name_example" <!-- Opening tag for the form element with the name attribute set to "name_example" -->
action="https://www.w3resource.com/html-css-exercise/basic/solution/form-name-answer-demo.php" method="get"><!-- Attributes specifying the action URL and method for the form -->
Name : <input type="text" name="name"/><br/><!-- Input field for entering a name -->
<label>Favorite Sports <!-- Label for the select element -->
</label>
<select name="favourite_sports" ><!-- Select element for choosing favorite sports -->
<option value="Soccer">Soccer</option><!-- Option for soccer -->
<option value="Hockey">Hockey</option><!-- Option for hockey -->
<option value="Tennis">Tennis</option><!-- Option for tennis -->
<option value="Golf">Golf</option><!-- Option for golf -->
</select><br/><!-- Closing tag for the select element -->
<label>Describe yourself in short : <!-- Label for the textarea element -->
</label><br/><!-- Line break -->
<textarea cols="10" rows="10" name="descript"><!-- Textarea element for describing oneself -->
</textarea><br/><!-- Closing tag for the textarea element -->
<button type="submit" <!-- Button element for submitting the form -->
name="submit">Submit</button><!-- Button with the name attribute set to "submit" -->
</form><!-- Closing tag for the form element -->
</body><!-- Closing tag for the document's body section -->
</html><!-- Closing tag for the root element of the HTML document -->
Explanation:
Live Demo :
See the Pen form-name-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4