Using brackets in html and css []

Using brackets in html and css []
0

#1

i looked at a page and i saw in the html something like that:

<li data-row-index="2">

and in the css:

li[data-row-index="2"]{
font-size: 16px
}

what does the bracket do? i know brackets purpose in java script but not in html and css.


#2

It’s called an ‘attribute selector’. See this SO answer: https://stackoverflow.com/questions/15604182/why-use-an-attribute-selector-to-match-classes or these docs: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors