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 trialRyan Boyd
7,561 PointsHow to get Label inside of form box?
Curious to know how you would place the label inside of the actual form box? For example, it would display "label" inside the box until the user clicked in the box and it would disappear. I've noticed this on some forms and was curious what the HTML syntax would look like.
4 Answers
Jesse Hall
4,275 PointsEveryone mentioned this but here's how it looks for those who don't want to click away from the site:
<input type="text" id="name" name="user_name" placeholder="Name">
Adam Mould
5,458 PointsHi Ryan,
I believe you're looking for input placeholder.
Keep in mind placeholder does not work for < IE10, but there are JavaScript polyfills available such as Placeholder.js if you still wish to support older browsers.
Clinton Hopgood
7,825 PointsThe value attribute is what you're looking for.
Jonathan Cousins
4,160 PointsFrom Adam Mould's post:
Hi Ryan,
I believe you're looking for input placeholder.
Keep in mind placeholder does not work for < IE10, but there are JavaScript polyfills available such as Placeholder.js if you still wish to support older browsers.
The placeholder attribute is your best bet. A complete list of browsers which support the placeholder attribute.
Ryan Boyd
7,561 PointsRyan Boyd
7,561 PointsNice, thanks Adam and Jonathan!