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

CSS CSS Selectors Selectors - Beyond the Basics Attribute Selectors

Matthew Keys
Matthew Keys
1,922 Points

Confused regarding "for" and "type" and stuff like that

Hi. I am getting quite confused and I was just wondering, can someone please explain what all of the tags mean, such as type, for, value etc.

1 Answer

andren
andren
28,558 Points

They are attributes that belong to the label/input elements.

The for attribute specifies what input element the label is associated with, the value of for should match the id attribute of an input element.

The type attribute defines the type of input element you want. An input element has many forms, it can be a text input, a password input, email input, color input, checkbox input, etc. The type attribute is the thing that determines which type of input you end up with.

The value attribute essentially defines either the default value of an input or simply the text that is displayed on it depending on which type of input you use it on.

The placeholder attribute defines a placeholder text that is shown on an input before you start typing on it, usually it is some short descriptive text that clarifies what you are meant to enter into the input.

If you want more details Treehouse has an entire course dedicated to HTML Forms which should answer any question you might have.

Matthew Keys
Matthew Keys
1,922 Points

Thank you for the clear answer, appreciate it.