Labels are used to make inputs more accessible.
for
- the ID of the corresponding input
The button element is a clickable element inside of your HTML. The button element can contain content of multiple types inside it.
type
- defines default behavior of the button.
button
reset
- Clears inputs when in a formsubmit
- Triggers a form submissionName
Value
Input elements are the primary way we retrieve information from the user.
There are many different attributes available to us, but we are only going to focus on the basics
id
and class
type
- sets the behavior of the input name
- represents the input's name inside a form.value
- represents the current text or value for the inputplaceholder
- text displayed before the element is filled out.The text input is the most commonly used html input you will use. It represents a single line text.
See the Pen UA-ITR-Froms3 by Jon (@Middaugh) on CodePen.
The Password Input is very similar to the text input, but any text put in the textbox will be represented with circles or asterisks.
See the Pen UA-ITR-Froms4 by Jon (@Middaugh) on CodePen.
Radio inputs provide the user a list of items where only one can be selected
name
value
checked
Yes
No
Maybe
See the Pen UA-ITR-From5 by Jon (@Middaugh) on CodePen.
Radio inputs provide the user a list of items where only one can be selected
name
value
checked
Yes
No
select
element
Selects, or dropdowns, are used to provide the user the ability to select one of many options. Selects
are composed posed of option
tags.
option
element
Option
are only used inside select
elements.
selected
value
See the Pen UA-ITR-From6 by Jon (@Middaugh) on CodePen.
<form> Content </form>
action
- Represents the url where we are sending the data.method
- specifies the HTTP method used
get
post
name
autocomplete
novalidate
The number input allows only numbers. On a mobile device, it will bring up a numeric keyboard.
The email input provides in browser validation for the user.
Hidden inputs act as they are named. They are hidden on the page, but are submitted by the form
Allows the user to select a file off their computer for upload
Behaves similar to a text field. Different browsers handle it in different ways.
An input for telephones. Requires a pattern for proper implementation.
Behaves similar to a text field. Phones add a '.com'
Some of these were introduced in HTML5 and help enforce rules without JavaScript
autocomplete
Enables or disables autocomplete on an input box. It accepts the value of "on" or "off"
autofocus
Tells the browser what input should have focus when the page is loaded. It does not require a value
min
and max
Sets the min and maximum values a numeric input can have
maxlength
Sets the maximum number of characters for an input
required
Tells the browser that this element must be filled out before we submit the form. It does not require a value.
The attribute selector allows you to select elements by their attributes or attribute values.
[attr] { /*css*/ }
[target] { /*css*/ }
a[target] { /*css*/ }
Link
Link
See the Pen UA-ITR-ATTR-Selector by Jon (@Middaugh) on CodePen.
[attr="value"] { /*css*/ }
[type="text"] { /*css*/ }
input[type="text"] { /*css*/ }
[href^="https"] { /*css*/ }
Google
[href$=".com"] { /*css*/ }
Google
[href*="google"] { /*css*/ }
Google
Most inputs have default styling that we've been looking at for years.
We override the default values.