Table Text

In HTML, table text is the text that is located within an HTML table. Often you will want your table text to appear different to the other text on the page. This page contains table text codes for applying styles to the text within your HTML tables.

To style the text within a table, you use the same CSS properties that you would use in styling any text. The thing to remember is that, you need to know which HTML element to apply the style against. For example, to change the text color across the whole table, use the color property against the <table> tag. But to change the text color in only the table header, you should only apply that property to the <thead> element, or alternatively, to each individual <th> tag (or the <<tr> tag that contains the table headers).

Below are some examples of applying styles against table text in HTML.

Whole Table

This example applies various styles against the text in the whole table. Therefore, I apply the styles against the <table> tag.

Like this:

Source CodeResult
Table HeaderTable Header
Table cell 1Table cell 2
Table cell 3Table cell 4

Table Row

To change the text style in a whole table row, you can apply the CSS against the <tr> tag.

Example:

Source CodeResult
Table HeaderTable Header
Table cell 1Table cell 2
Table cell 3Table cell 4

Table Text with CSS Classes

Using CSS classes is a more efficient way of setting your styles. You simply create a class (using a name of your choosing), then apply styles against that class. Then you can refer to that class from anywhere within your HTML document.

Here's an example of using an embedded style sheet to define the styles of your HTML tables. Note that the styles are set in between the opening and closing <style> tags.

Source CodeResult
Table HeaderTable Header
Table cell 1. The text in this table has had 'line-height' applied. This results in a larger space in between each line of text.Table cell 2
Table cell 3Table cell 4