표준은 ::placeholder 하나다(2020년부터 전 브라우저).1 아래는 그 전의 접두사와 IE·레거시 Edge 전용 컨트롤.
::-webkit-input-placeholder /* for (Chrome/Safari/Opera) */
:-ms-input-placeholder /* for IE. */
::-ms-input-placeholder /* for Edge (also supports webkit prefix) */
::-ms-clear {}
::-ms-reveal {}
Footnotes
-
::placeholder - MDN: “The ::placeholder CSS pseudo-element represents the placeholder text in an or — Baseline: “It’s been available across browsers since January 2020.” ↩
autocomplete="one-time-code" 는 이 칸이 OTP 라고 브라우저에 알리는 힌트다 — SMS 로 온 코드를 OS·키보드가 제안한다.1 JS 로 직접 받으려면 WebOTP(navigator.credentials.get({ otp }))인데, SMS 마지막 줄이 @도메인 #코드 형식이어야 한다.2
<input
type="text"
inputmode="numeric"
autocomplete="one-time-code"
pattern="\d{6}"
required
/>
const otp = await navigator.credentials.get({
otp: {
transport: ['sms']
}
})
input.value = otp.code
참고
- SMS OTP form best practices
- Apple Developer Documentation
- HTML attributes to improve your users’ two factor authentication experience
Footnotes
-
HTML attribute: autocomplete - MDN: “A one-time password (OTP) for verifying user identity that is used as an additional factor in a sign-in flow. Most commonly this is a code received via some out-of-channel mechanism, such as SMS, email, or authenticator application.” ↩
-
WebOTP API - MDN: “The last line is mandatory. It must be the last line if there are others present, and must consist of: The domain part of the URL of the website that invoked the API, preceded by a @. Followed by a space. Followed by the OTP, preceded by a pound sign (#).” ↩
Footnotes
field-sizing를 사용하면 콘텐츠를 기반으로 크기 조절을 사용 설정하는 데 CSS 한 줄이 필요합니다. 이 콘텐츠 기반 크기 조절 스타일은textarea외에도 다른 요소에도 적용됩니다.