HTML: Forms, Inputs & Accessibility Flashcards

Form elements: , , , , Input types (text, email, number, date, etc.) Form validation (HTML5 attributes like required, pattern) Accessibility roles and attributes (ARIA) Interview-style Questions: How do you ensure a form is accessible? What are the pros and cons of client-side HTML validation? When would you use aria-hidden="true"? (21 cards)

1
Q

What does the <form> element do in HTML?

A

The <form> element is used to collect user input and submit it to a server or handle it with JavaScript.

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

What are common HTML input elements?

A

<input></input>, <textarea>, <select>, and <label> are commonly used to gather various types of user input.</label></select></textarea>

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

What is the purpose of the <label> tag?</label>

A

<label> improves accessibility by associating text with a form control, allowing screen readers and users to interact more easily.</label>

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

What are HTML5 input types?

A

HTML5 includes types like text, email, number, date, checkbox, radio, file, and password for tailored data collection.

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

What is the use of the ‘required’ attribute?

A

It marks a field as mandatory, preventing form submission unless filled out.

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

What is the purpose of the ‘pattern’ attribute in input fields?

A

It defines a regular expression that the input value must match, useful for custom validation like phone numbers or postal codes.

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

What are the pros of HTML5 form validation?

A

It provides instant feedback, reduces server load, and improves user experience without JavaScript.

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

What are the cons of HTML5 form validation?

A

It’s not supported uniformly in all browsers and should not replace server-side validation for security.

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

How can you ensure a form is accessible?

A

Use <label> with ‘for’, associate controls correctly, use ARIA attributes when needed, and maintain a logical tab order.</label>

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

When would you use aria-hidden="true"?

A

To hide non-essential content from screen readers, such as decorative elements or duplicate visual cues.

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

What are ARIA roles and attributes?

A

ARIA (Accessible Rich Internet Applications) defines roles and attributes that help screen readers understand complex UIs.

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

What is a best practice for using <select> tags?</select>

A

Include a default option like ‘Please choose’ and ensure each <option> is descriptive and useful.</option>

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

What is a use case for <textarea>?</textarea>

A

<textarea> is used when the user needs to input multi-line text, such as comments or reviews.
</textarea>

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

What are the advantages of using semantic form elements?

A

They improve accessibility, maintainability, and enhance user experience across devices and assistive technologies.

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

What are the disadvantages of non-semantic form markup?

A

It reduces accessibility, causes confusion in screen readers, and increases development and maintenance costs.

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

What is a common mistake when using <label> and <input></input>?</label>

A

Not associating them properly using ‘for’ and ‘id’, which breaks accessibility.

17
Q

What is the impact of accessible forms on system design?

A

They ensure inclusivity, compliance with accessibility standards, and reduce user friction across diverse user bases.

18
Q

What is a real-world tradeoff with form validation?

A

Client-side validation improves speed and UX, but must be supplemented with server-side checks for security.

19
Q

What are architectural implications of poor form design?

A

It can lead to inaccessible systems, inconsistent behavior, and higher technical debt during feature expansion or redesign.

20
Q

How does form structure affect performance and fault tolerance?

A

Simpler, semantic forms reduce DOM complexity and potential user error, making the frontend more resilient and easier to debug.

21
Q

What are common interview questions about forms and accessibility?

A

‘How do you make a form accessible?’, ‘What are input types in HTML?’, ‘Explain HTML5 form validation.’