HTML and CSS Reference
In-Depth Information
Easy? Half of them are valid and half of them invalid; Pitr will tell you
which ones are which at the end of the section. Note that by
valid
we
mean they're constructed correctly, not that you'll be able to send email
to them successfully. The reason you'd be almost certainly wrong if you
implemented an email field yourself is that even the experts can't agree
on what a valid email address looks like. The
HTML5
spec itself is
“willfully violating” the standard:
A valid e-mail address is a string that matches the
ABNF
production
1*(
atext / “.” ) “@" ldh-str 1*( “.” ldh-str )
where
atext
is defined
in
RFC 5322
section 3.2.3, and
ldh-str
is defined in
RFC 1034
section 3.5.
This requirement is a willful violation of
RFC 5322
, which defines a
syntax for e-mail addresses that is simultaneously too strict (before the
“@”
character), too vague (after the
“@”
character), and too lax
(allowing comments, whitespace characters, and quoted strings in
manners unfamiliar to most users) to be of practical use here.
Here's the code for this
email
input:
<input type="email">
Visually it looks the same as a normal
text input.
If you type in an invalid email address
and submit the form, you'll get an error
message similar to the one shown here.
In HTML5, the invalid emails
addresses are beink 3, 4, 7, 8, and 9.
1, 2, 5, 6, and 10 are beink valid.