Skip to content

Commit f88bada

Browse files
committed
Place input elements inside label elements in login form
1 parent d715f34 commit f88bada

File tree

2 files changed

+66
-58
lines changed

2 files changed

+66
-58
lines changed

src/content/5/en/part5a.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,24 @@ const App = () => {
5757
<h2>Login</h2>
5858
<form onSubmit={handleLogin}>
5959
<div>
60-
<label htmlFor="username">username</label>
61-
<input
62-
type="text"
63-
id="username"
64-
value={username}
65-
onChange={({ target }) => setUsername(target.value)}
66-
/>
60+
<label>
61+
username
62+
<input
63+
type="text"
64+
value={username}
65+
onChange={({ target }) => setUsername(target.value)}
66+
/>
67+
</label>
6768
</div>
6869
<div>
69-
<label htmlFor="password">password</label>
70-
<input
71-
type="password"
72-
id="password"
73-
value={password}
74-
onChange={({ target }) => setPassword(target.value)}
75-
/>
70+
<label>
71+
password
72+
<input
73+
type="password"
74+
value={password}
75+
onChange={({ target }) => setPassword(target.value)}
76+
/>
77+
</label>
7678
</div>
7779
<button type="submit">login</button>
7880
</form>
@@ -134,7 +136,7 @@ const App = () => {
134136

135137
// ...
136138

137-
const handleLogin = async event => {
139+
const handleLogin = async event => { // highlight-line
138140
event.preventDefault()
139141

140142
// highlight-start
@@ -173,22 +175,24 @@ const App = () => {
173175
const loginForm = () => (
174176
<form onSubmit={handleLogin}>
175177
<div>
176-
<label htmlFor="username">username</label>
177-
<input
178-
type="text"
179-
id="username"
180-
value={username}
181-
onChange={({ target }) => setUsername(target.value)}
182-
/>
178+
<label>
179+
username
180+
<input
181+
type="text"
182+
value={username}
183+
onChange={({ target }) => setUsername(target.value)}
184+
/>
185+
</label>
183186
</div>
184187
<div>
185-
<label htmlFor="password">password</label>
186-
<input
187-
type="password"
188-
id="password"
189-
value={password}
190-
onChange={({ target }) => setPassword(target.value)}
191-
/>
188+
<label>
189+
password
190+
<input
191+
type="password"
192+
value={password}
193+
onChange={({ target }) => setPassword(target.value)}
194+
/>
195+
</label>
192196
</div>
193197
<button type="submit">login</button>
194198
</form>

src/content/5/fi/osa5a.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,24 @@ const App = () => {
5757
<h2>Login</h2>
5858
<form onSubmit={handleLogin}>
5959
<div>
60-
<label htmlFor="username">username</label>
61-
<input
62-
type="text"
63-
id="username"
64-
value={username}
65-
onChange={({ target }) => setUsername(target.value)}
66-
/>
60+
<label>
61+
username
62+
<input
63+
type="text"
64+
value={username}
65+
onChange={({ target }) => setUsername(target.value)}
66+
/>
67+
</label>
6768
</div>
6869
<div>
69-
<label htmlFor="password">password</label>
70-
<input
71-
type="password"
72-
id="password"
73-
value={password}
74-
onChange={({ target }) => setPassword(target.value)}
75-
/>
70+
<label>
71+
password
72+
<input
73+
type="password"
74+
value={password}
75+
onChange={({ target }) => setPassword(target.value)}
76+
/>
77+
</label>
7678
</div>
7779
<button type="submit">login</button>
7880
</form>
@@ -129,7 +131,7 @@ const App = () => {
129131

130132
// ...
131133

132-
const handleLogin = async event => {
134+
const handleLogin = async event => { // highlight-line
133135
event.preventDefault()
134136

135137
// highlight-start
@@ -168,22 +170,24 @@ const App = () => {
168170
const loginForm = () => (
169171
<form onSubmit={handleLogin}>
170172
<div>
171-
<label htmlFor="username">username</label>
172-
<input
173-
type="text"
174-
id="username"
175-
value={username}
176-
onChange={({ target }) => setUsername(target.value)}
177-
/>
173+
<label>
174+
username
175+
<input
176+
type="text"
177+
value={username}
178+
onChange={({ target }) => setUsername(target.value)}
179+
/>
180+
</label>
178181
</div>
179182
<div>
180-
<label htmlFor="password">password</label>
181-
<input
182-
type="password"
183-
id="password"
184-
value={password}
185-
onChange={({ target }) => setPassword(target.value)}
186-
/>
183+
<label>
184+
password
185+
<input
186+
type="password"
187+
value={password}
188+
onChange={({ target }) => setPassword(target.value)}
189+
/>
190+
</label>
187191
</div>
188192
<button type="submit">login</button>
189193
</form>

0 commit comments

Comments
 (0)