Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed HTML Forms!
You have completed HTML Forms!
Preview
A text input isn't ideal for every situation. The select element can be used in cases where the user should pick from a set of predefined options.
HTML Elements
- The
select-element renders a drop-down menu that contains selectable options. This type of form control is ideal for scenarios where the user must choose one option from a preset list of 5 or more choices. - The
option-element represents one of the choices that a user can choose in a select menu. It should always be nested inside of a select element. - The
optgroup-element wraps one or more option elements and helps to create logical groups. The label attribute specifies the text that the optgroup should display above the nested options.
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
the user to be able to type in text.
0:00
Rather, you might want them to pick from
some preset options that you define.
0:01
Let's say that our imaginary web app is
targeted
0:06
at people like you, that are students of
technology.
0:09
We want to allow people to select from a
predefined list of job roles.
0:12
We're going to have a lot of job roles to
0:18
chose from, so any time that you have a
list of
0:20
options that's longer than, say, four or
five things, it's
0:23
best to go with a select menu because it
saves space.
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up