diffsnack
HTML Find the mistake Level 4

HTML exercise: Form fields and labels — Find the bug.

The "Your name" field should start empty and show "Max Muster" only as a faint hint that disappears when you type.

The exercise

Find the bug.

1<form action="/contact" method="post">
2 <label for="name">Your name</label>
3 <input type="text" id="name"
4 name="name" value="Max Muster">
5 <button type="submit">Send</button>
6</form>

Solution

The bug is in line 4.

- name="name" value="Max Muster">
+ name="name" placeholder="Max Muster">

value puts real starting text into the box, so visitors have to delete it and it gets sent if they do not. placeholder leaves the field empty and shows only a hint that disappears as you type.

Play this exercise Learn the concept: Form fields and labels