Forms and Inputs Flashcards

1
Q

What are forms?

A

Forms are containers that hold a set of inputs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are inputs?

A

Inputs are individual components that a user interacts with - typically corresponding to a single data point.

HTML provides numerous input types (text, email, number, password, etc.), and input types differ in how they are rendered. Inputs also vary in how they are validated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What doest the <form> element do?

A

The

<form> element wraps all our inputs and labels.
</form>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the action attribute?

A

The action attribute is the URL of the server endpoint that submitted form data should be sent to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the method attribute?

A

The method attribute is the request method that the browser should use when sending the data to the server.

Usually you’ll want method=”post”, but method=”get” is also possible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the fieldset element?

A

Used to group together related inputs and labels.

The main reason to use fieldsets is that they help web crawlers and screen readers understand how inputs are grouped together (even if this is not revealed visually to sighted users).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the legend element?

A

It is like the title for the fieldset.

For screen readers, it adds extra context to the inputs in the fieldset.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What do labels do?

A

Labels tell human users, web crawlers, and screen readers what an input is for -using the for attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the for attribute?

A

It goes on a label and its value should be set to the ID of the input it is for.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the placeholder attribute?

A

Input attribute.

Used to set text that initially displays before the user has input any data.

Because they are meant to offer examples of desired input, they should not be used in place of labels.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the required attribute?

A

Input attribute.

Used to indicate that an input must be filled out.

When the user submits the form, if there are any required child inputs on the form, the browser will display a message telling the user where they need to supply data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the pattern attribute?

A

Input attribute.

Used to supply regular expression patterns that the user’s input must match in order to be valid.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the type attribute?

A

Input attribute.

This attribute determines how the element looks and how its validation works.

Input types also provide some accessibility by dictating the kind of keyboard a smartphone will display for a user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the select and option elements?

A

The element is used to let users choose from a list of options. tags wrap a set of one or more options, and you can pre-select an individual

by adding the selected attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the button element?

A

Can use elements to allow users to submit and reset the form.

This is done by setting the type attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the accessibility tree?

A

The accessibility information for forms, and all other DOM elements, is stored in the accessibility tree.

ARIA uses this tree to send information to and receive information from assistive devices such as screen readers.

This tree stores the roles of the form elements, the elements’ accessible names (determined by their labels), the state the form elements are in (if a radio is selected or unselected), and how to interact with those elements.

All of this information will be relayed by a screen reader when the user arrives at a given element, and it will be updated and relayed again when a user does something to change it.

17
Q

What principle should you strive to follow when designing forms?

A

Keep them short, simple, and as semantic as possible.

Remember, forms require a user to do something, and you want to make it as intuitive as possible to do that thing. If you make an inaccessible form or put too much distance between start and end of the form, the user is less likely to follow through.