css - How to apply style to a class or id with changing index? -


i have style this:

#detailtable4 tbody tr td:last-child {   background-color: #7e0303; } 

i apply elements #detailtable (no matter of index 1,2...# end). possible css?

you can use id starts attribute selector in below snippet. [id^="detailtable"] selector match element id starts detailtable.

[id^="detailtable"] tbody tr td:last-child {    background-color: #7e0303;  }
<table id='detailtable1'>    <tbody>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>    </tbody>  </table>    <table id='detailtable2'>    <tbody>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>    </tbody>  </table>    <table id='detailtable4'>    <tbody>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>    </tbody>  </table>    <table id='detailtable-abcd'>    <tbody>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>      <tr>        <td>one</td>        <td>two</td>        <td>three</td>      </tr>    </tbody>  </table>


Comments