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 开发者_C百科it for the whole cell, but how do you do it for only specific pieces of text?
<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.
Wrap the text to which you are interested in adding css in a span. Note that if you want the text centered in a column you probabaly want to apply "align:center" to the <td> and not the span.
For example:
<tr> <td><span class="classForEverythingButCentering">not centered</span></td> <td style="align:center">centered</td> <td class="centered">differently centered (if you setup a class named .centered or perhaps td.centered).</td> </tr>
精彩评论