All repair missions / Mission 03
Fix this page
Give the field a name
Connect a visible label to a form field.
Your goal
Give the text field a visible, associated label reading “Project name”. Keep the field usable. Click the label to try focusing the field. This practice form cannot send data.
Edit a short HTML fragment or CSS rules. Changes apply when you press Update preview or Check my repair. Scripts, links, images and external resources are excluded from this small practice area. Edits stay in this page’s memory; reloading starts again.
Your working preview
Read one possible solution
<form>
<label for="project-name">Project name</label>
<input id="project-name" type="text" placeholder="My first website">
<button type="button">Preview project</button>
</form>label, input, button { display: block; margin-bottom: 16px; }
input, button { font: inherit; padding: 10px; }
button { background: #ff7700; color: #20212a; border: 0; border-radius: 6px; }An associated label supplies the field’s accessible name and a larger click target. A placeholder disappears while typing and does not replace a visible label. Both an explicit for/id relationship and a wrapping label can work.
Starting code and all hints
<form>
<p>Project name</p>
<input id="project-name" type="text" placeholder="My first website">
<button type="button">Preview project</button>
</form>label, input, button { display: block; margin-bottom: 16px; }
input, button { font: inherit; padding: 10px; }
button { background: #ff7700; color: #20212a; border: 0; border-radius: 6px; }- A nearby paragraph does not establish a label relationship.
- Use a label element. Its for attribute should match the input id.
- Replace the paragraph with <label for="project-name">Project name</label>. Wrapping the input in a label is another valid approach.