강의

멘토링

커뮤니티

Inflearn Community Q&A

dltkdi1730170's profile image
dltkdi1730170

asked

Learn HTML, CSS, and web standards properly to get a job as a publisher

Learn about Form Controls

form 컨트롤 속성 질문!

Written on

·

183

1

성별 선택 폼 이렇게 알려주ㅅ셨는데요,

<p>

<span> 성별 </span>

<label for="male">남자</label>

<input type="radio" id="male" name="choice" value="male"> 

<label for="female">여자</label>

<input type="radio" id="female" name="choice" value="female">

</p>

혹시 아래와 같이 label 안에 input 두 가지를 다 넣고 id 없이 name만 같게 해줘도 html 규칙상 문제가 안생기나요? 일단 브라우저에서는 동일하게 기능하더라고요!

<p>

<label for="">성별은?<input type="radio" name="gender" value="1">남자

<input type="radio" name="gender" value="2">여자</label>

</p>

웹 디자인HTML/CSS

Answer 1

1

Dongho Lee님의 프로필 이미지
Dongho Lee
Instructor

label에 for없이 작성하려면 input을 감싸면 됩니다만 각각 감싸는 것이 적당합니다.

<label>
    <input type="radio" name="gender" value="male"> 남자
</label>
<label>
    <input type="radio" name="gender" value="female"> 여자
</label>

dltkdi1730170's profile image
dltkdi1730170

asked

Ask a question