14

Is there a way to set the focus in a specific HTML input (a textarea control, actually), without using Javascript?

EDIT: Is possible in HTML5 but the question is about HTML < 5

GClaramunt
  • 3,148
  • 1
  • 21
  • 35

4 Answers4

17

You can use autofocus in HTML5 documents, but it has little support at present (see chart).

Matt
  • 74,352
  • 26
  • 153
  • 180
Tgr
  • 27,442
  • 12
  • 81
  • 118
11

Nope. Sadly JavaScript is required, because it's dynamically modifying the browser on the client-side (what JavaScript was made for).

Andrew Dunkman
  • 1,131
  • 2
  • 8
  • 18
  • 10
    I see people are still viewing this post; this is slightly incorrect with HTML5. In HTML5-compliant browsers, you can add `` to your tag to auto-focus the element when the page loads without javascript. Check http://wufoo.com/html5/attributes/02-autofocus.html for details. – Andrew Dunkman Apr 12 '12 at 20:34
0

I don't know of any, other than tabbing to the field or clicking within it.

D'Arcy Rittich
  • 167,292
  • 40
  • 290
  • 283
0

It depends on how and when you want to set the focus on this textarea. "tabindex" might help you.

Alsciende
  • 26,583
  • 9
  • 51
  • 67