Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,945 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