폼 개요 (Forms overview)
모든 폼 요소는 순수 시맨틱 HTML만으로 완전히 반응형이라, 다양한 기기와 뷰포트에서도 자연스럽게 크기가 조절돼요. 폼을 만들 때 부담 없이 사용할 수 있답니다.
입력 요소는 기본적으로 width: 100%;이며, 버튼과 같은 크기로 맞춰져 있어 일관성 있는 폼을 구성할 수 있어요.
출처: 문서
본문
<form>
<fieldset>
<label>
First name
<input
name="first_name"
placeholder="First name"
autocomplete="given-name"
/>
</label>
<label>
Email
<input
type="email"
name="email"
placeholder="Email"
autocomplete="email"
/>
</label>
</fieldset>
<input
type="submit"
value="Subscribe"
/>
</form>
<input>은 <label> 안에 넣을 수도 있고 밖에 둘 수도 있어요.
<form>
<!-- Input inside label -->
<label>
First name
<input
name="first_name"
placeholder="First name"
autocomplete="given-name"
/>
</label>
<!-- Input outside label -->
<label for="email">Email</label>
<input
type="email"
id="email"
placeholder="Email"
autocomplete="email"
/>
</form>
도움말 텍스트 (Helper text)
폼 요소 아래에 있는 <small>은 흐리게(muted) 표시되며 도움말 텍스트 역할을 해요.
<input
type="email"
name="email"
placeholder="Email"
autoComplete="email"
aria-label="Email"
aria-describedby="email-helper"
/>
<small id="email-helper">
We'll never share your email with anyone else.
</small>
그리드와 함께 사용하기 (Usage with grid)
폼 안에서 .grid를 사용할 수 있어요. 자세한 내용은 Grid를 참고하세요.
<form>
<fieldset class="grid">
<input
name="login"
placeholder="Login"
aria-label="Login"
autocomplete="username"
/>
<input
type="password"
name="password"
placeholder="Password"
aria-label="Password"
autocomplete="current-password"
/>
<input
type="submit"
value="Log in"
/>
</fieldset>
</form>
그룹과 함께 사용하기 (Usage with group)
폼 요소와 함께 role="group"을 사용할 수 있어요. 자세한 내용은 Group을 참고하세요.
<form>
<fieldset role="group">
<input
type="email"
name="email"
placeholder="Enter your email"
autocomplete="email"
/>
<input type="submit" value="Subscribe" />
</fieldset>
</form>