JSFiddle - React, Tailwind, and code Playground

HTML

<table class='objectTable'>
    <caption>Caption Table</caption>
    <tr>
        <th>A</th>
        <th>B</th>
    </tr>
    <tr>
        <td>1</td>
        <td>2</td>
    </tr>
</table>
<br/><br/>
<span>No Caption Table</span>
<table class='objectTable'>
    <tr>
        <th>C</th>
        <th>D</th>
    </tr>
    <tr>
        <td>3</td>
        <td>4</td>
    </tr>
</table>

CSS

.objectTable th:first-child
{
    background-color: blue;
    color: white;
}

.objectTable caption + tr th:first-child
{
    background-color: red;
}