I am trying to figure out how to use the HTML property tabindex through css.
I specifically want to add tabIndex=0 to all the div elements that contain a className='my-checkbox'.
This is what I have:
<div tabIndex="0" className="my-checkbox">
...
<div>
Since my <div className="my-checkbox"> is repeated multiple times across my application, I don't want to explicitly define the tabIndex property every time; thus I am looking for a way to avoid code duplication.
How can I add a tabIndex=0 property to all the div elements that contain a className="my-checkbox"?
I tried to add the following css rule, but that didn't work:
div .my-checkbox-img {
tab-index: '0'
}
This adds a tab-index style that seems to not be functional; Google Chrome debugger shows it as an unknown property.
I tried nav-index but that seems to be deprecated as well.
To sum my question in threefold:
- What's the difference between styles and properties? I was looking for something more detailed than this SO answer.
- How are html properties related to css attributes (such as
tabIndextotab-indexand so on)? - How can I add a
tabIndex=0property to all thedivelements that contain aclassName="my-checkbox"?
