I know I can set an element to be focused on document load using JS/jQuery:
$('#myInput').focus();
My question is if it's possible to do it using CSS only, no script.
I know I can set an element to be focused on document load using JS/jQuery:
$('#myInput').focus();
My question is if it's possible to do it using CSS only, no script.
It is not possible to set focus in CSS. It’s not the kind of things CSS is designed for, as it is a behavior issue.
As noted in a comment, in HTML you can set initial focus using the autofocus
attribute.