The kind of input, such as text, password, or radio.
value
The input’s value.
readonly
Prevents the user from editing supported input types.
disabled
Disables the control.
size
The approximate visible width in characters for supported inputs.
maxlength
The maximum text length.
min / max
Minimum and maximum values for supported types.
pattern
A pattern that the input value must match.
placeholder
A hint showing the expected value.
required
Makes the field mandatory where supported.
autofocus
Requests initial focus for the control.
10. Input types
Type
Description
checkbox
A checkbox for an independent choice.
color
A color picker.
date
A year, month, and day.
email
An email address, with format validation.
file
A file picker.
image
An image used as a submit button.
month
A month and year.
number
A numeric input, with optional bounds.
password
A text field that masks its value.
radio
One choice from a group.
range
A slider for a range of numbers.
search
A search field.
submit
A button that submits the form.
tel
A telephone number field.
text
A single-line text field.
time
A time value.
url
A URL, with format validation.
week
A year and week number.
11. Patterns and regular expressions
For compatible inputs, the pattern attribute tests the whole entered value. Give the user a plain-language hint for the expected format.
Pattern
Meaning
.
Any character except a line terminator by default.
[abc]
One of a, b, or c.
[^abc]
Any character outside the set.
[a-g]
A character in the range a to g.
(a|b)
Either a or b.
^abc
Matches abc at the beginning.
abc$
Matches abc at the end.
\w \d \s
A word character, a digit, or whitespace.
\W \D \S
The corresponding opposite character classes.
\t \n \r
Tab, newline, or carriage return.
a* a+ a?
Zero or more, one or more, or zero or one occurrence.
a{5} a{2,} a{1,3}
Exactly five, at least two, or between one and three occurrences.
12. Tables
Element
Description
<table>
Creates a table.
<caption>
Provides its title or caption.
<tr>
Defines a row.
<td>
Defines a data cell.
<th>
Defines a header cell.
13. Embedded content
Element
Description
<img>
Displays an image.
<iframe>
Embeds another HTML document.
<embed>
Embeds external content.
<object>
Embeds an external resource.
<video>
Plays a video.
<audio>
Plays audio.
<source>
Supplies an alternative image, audio, or video resource.
<canvas>
Provides a scriptable drawing surface.
<svg>
Defines vector graphics.
14. Block-level elements
A typical block box begins on a new line in normal flow and takes up the available inline width. Examples include paragraphs and div elements. CSS can change an element’s display behavior.
15. Inline elements
Inline boxes flow within a line of text. Links, spans, and emphasized text normally have this behavior.
16. In-page links and anchors
<a href="#contact">Jump to contact</a>
<h2 id="contact">Contact</h2>
17. Metadata
Metadata
Description
<title>
Sets the document title.
<meta charset="UTF-8">
Declares the character encoding.
<meta name="description" content="">
Summarizes the page. Search engines may use it in a result snippet.
<meta name="keywords" content="">
Lists keywords. Google does not use this metadata for web search ranking.
<meta name="viewport" content="">
Controls the mobile viewport.
<meta name="author" content="">
Names the document author.
<meta name="copyright" content="">
Indicates copyright information.
<meta name="robots" content="">
Controls aspects of how compatible crawlers process the page.