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

What CSS is needed to make a text box automatically active when the sign in page opens?

I noticed that when I Googled "Treehouse Sign in" and clicked on the Sign in page, the text box for "Name" was automatically "active" and the cursor was blinking as if I'd clicked on the box myself. But if I have been doing a lesson and sign out, then go to sign in again later from the drop down arrow on that same page, when the Sign In box pops up, the "Name" text box is NOT active and the cursor isn't blinking inside of it -- until I click on the Name text box myself. Does anyone know what code is needed to automatically activate a text box when a page is opened or a text box pops up on a page?

1 Answer

Rebecca Bompiani
Rebecca Bompiani
16,948 Points

Hi Heather-

This is known as "autofocus" and is generally an attribute of the HTML input

Name: <input type="text" name="tName" autofocus>

Thanks Rebecca