Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Forms Choosing Options Select Menus

Narendra Joshi
Narendra Joshi
9,905 Points

Why did you an "_" when assigning value in option tag?

Was that just to make the code look good?

2 Answers

Steven Parker
Steven Parker
231,275 Points

You'll notice that as a convention, underscores are used both here and other parts of the program for names that are composed of more than one word. As you guessed, this is primarily for readability and has no special significance to the program. This is sometimes referred to as "snake case".

Another naming convention often used to improve readability is to capitalize the beginning of each joined word, known as "camel case" (for example: "thisIsCamelCase").

Anuj Bhusari
Anuj Bhusari
12,240 Points

Since you cannot use spaces in the names, for improving readability it is a common practice to use underscores instead of spaces.