HTML: How to specify a name for the button?
Solution:
HTML Code:
Explanation:
- This HTML document starts with a doctype declaration indicating it's an HTML5 document.
- Inside the <html> tags, the document structure begins.
- The <head> section contains metadata about the document, such as character encoding and the title.
- The <body> section is where the visible content of the webpage resides.
- Within the body section, there's a <form> element created with the action attribute set to the URL where the form data will be submitted and the method attribute set to "post".
- Inside the form, there are two <button> elements for selecting favorite topics.
- Both buttons have the name attribute set to "topic", indicating that they belong to the same group of data when the form is submitted.
- Each button has a different value attribute specifying the topic it represents (JavaScript or PHP).
- The HTML document ends with the closing </html> tag.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.