CSS in ID HTML atribute

How to add CSS to “ID = 5”?

<tr data-category-id="5" class="has-description no-logo">

You can target data attributes with CSS like this:

tr[data-category-id="5"] {
    background: red;

This not working(

I want each category to have its own background color

That CSS works for me on the category page to change the background color — is that where you’re trying to change it? Is it possible to provide a link to the page you’re trying to change?

How do I give my background color to each category?

Hmm, I’m not quite sure why the provided CSS wouldn’t work for you… here’s an example I’m able to build.


Thanks! It works :grinning:

1 Like