Can I shift focus to a div through CSS alone?

No, there isn't.

In normal circumstances, a div can't receive the focus at all, and CSS lacks anything to set the focus.


No CSS does not offer anything on focus. I know you said no JavaScript, but how easy:

document.getElementById('exampleId').focus();

Since none of the answers here worked for me (although I wanted focus on an input, not a div) I'll post one that does work:

autofocus

just like this:

<input autofocus>

Of course, the OP is asking for how to make this work with a div, which this doesn't. As was previously mentioned, contenteditable="yes" will make the div focusable, but this unfortunately doesn't work either:

<div contenteditable="yes" autofocus>
  This doesn't work!!
</div>

In my opinion, this is kind of an oversight in HTML5, this div should act like an input field. However, for the time being, it seems that javascript is required for this to happen.

Tags:

Html

Css