Search code examples
htmlbackgroundalignment

Changing the alignment and background color of specific text in a table


I am trying to change the alignment (center) and background color of only certain pieces of text within a table-cell. I know how to do it for the whole cell, but how do you do it for only specific pieces of text?


Solution

  • <td>
    <div style="text-align: right;">will be aligned right</div>
    <div style="background-color: #999;">will have a gray background</div>
    </td>
    

    It's better if you do this properly through a css stylesheet, this is just for illustrative purposes.