Performance: Form structure
Form structure affects page load speed and interaction responsiveness by influencing DOM size and event handling complexity.
<form><label for="name">Name</label><input id="name" type="text"><label for="email">Email</label><input id="email" type="email"><label for="message">Message</label><textarea id="message"></textarea></form>
<form><div><label>Name</label><input type="text"></div><div><label>Email</label><input type="email"></div><div><label>Message</label><textarea></textarea></div></form>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Form with many nested divs and missing label 'for' | High (many nodes) | Multiple reflows on input focus | Higher paint cost due to complex layout | [X] Bad |
| Semantic form with labels linked to inputs and minimal wrappers | Low (few nodes) | Single reflow on input focus | Lower paint cost with simpler layout | [OK] Good |
<form> element in HTML?<form> tag specifies where the form data is sent?<form action='/submit' method='post'> <input type='text' name='username' /> <button type='submit'>Send</button> </form>
<form action='/send' method='post'> <input type='text' name='email'> <button type='submit'>Submit</button> </form>
Pass the test and this pattern moves unknown