-2

I am facing issue while set tabindex through using css style, it's not applied on DIV and Ul Li.

Can anyone let me know solution?

I tried using this css

div:focus {
    border:1px solid #ddd;
}

Li:focus {
    border:1px solid #ddd;
}

Focus not coming on Div

Towkir
  • 3,889
  • 2
  • 22
  • 41
Banti Mathur
  • 41
  • 1
  • 5
  • You can't apply tabindex via css....only in the HTML. - https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex – Paulie_D Jun 18 '19 at 10:51
  • 1
    Have you set [tabindex attribute](https://stackoverflow.com/questions/4112289/what-is-the-html-tabindex-attribute) on those elements? – barbsan Jun 18 '19 at 10:54
  • if my answer is correct could you please accept it and vote it up? :) – xmaster Jun 18 '19 at 11:44

1 Answers1

1

You probarly forgot to set a tabindex like @barbsan mentioned. Second of all in your css Li has to be li.

div:focus { border: 1px solid #ddd; }
li:focus  { border: 1px solid #ddd; }
<div tabindex="0">
test
</div> 
<li tabindex="0">this is a li</li>
xmaster
  • 1,042
  • 7
  • 20