HTML5: How to specify a name for the fieldset?
Solution :
HTML Code :
JavaScript Code :
function ChangeColor(){ var fldname = document.getElementsByName("w3resource"); fldname[0].style.backgroundColor = '#C7E9FF'; }
Explanation:
- This HTML code represents a simple form containing text input fields and a button.
- The form has the name attribute set to "w3r_form".
- Inside the form, there is a fieldset element with the name attribute set to "w3resource". Fieldset is used to group related form elements.
- Inside the fieldset, there are three text input fields for entering name, email, and place respectively.
- There is also a button labeled "Change background color of fieldset". This button is associated with a JavaScript function named "ChangeColor()", which presumably changes the background color of the fieldset when clicked.
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.