How to get CSS to select IDs that begin with a string?

Spread the love

Sometimes, we want to get CSS to select IDs that begin with a string.

In this article, we’ll look at how to get CSS to select IDs that begin with a string.

How to get CSS to select IDs that begin with a string?

To get CSS to select IDs that begin with a string, we replace IDs with classes.

For instance, we write

<div id="product176" class="product"></div>
<div id="product177" class="product"></div>
<div id="product178" class="product"></div>

to add some divs.

Then we write

.product {
  //...
}

to select the divs with class product with .product.

Conclusion

To get CSS to select IDs that begin with a string, we replace IDs with classes.

Leave a Reply

Your email address will not be published.