I’m new to HTML. This is probably very basic, but no matter what I do, I can’t get my form to work. Whenever I click on an input field (text area), the input field will stay selected as long as I hold the mouse down, but whenever I release it, the focus goes right back to the first field of the form. Is this HTML/ CSS? I have no idea how to fix it.
This is the URL for the form I was working on (http://www.seanmccully.com/apps/langham/tea.html) — but it is probably fixed by now. You can see that you can’t select first name, last name, city, email (you can only enter data by tabbing).
It’s because you have wrapped all of the form elements in one
labelelement. Get rid of that and it will work fine.A
labelelement can only be associated with a single form control, and clicking on alabelwill give focus to its associated control. Since you have multiple controls within yourlabel, it is associated with the first, and as click events propagate up the DOM, clicks on any other form control will reach the label and cause it to give focus to its associated control (the first one).If you want to use
labelelements, you will need one for each control. You could change yourspanelements tolabelelements, and use theforattribute to associate that label with a control, or you could wrap each control in a label: