Controlling Styles for Table Content
There are multiple ways to control the look of content in tables. In this lesson, let's take a look at using cell content styles, as well as employing advanced selectors in a stylesheet.
[Menu Proxy — Headings — Online — Depth3 ]
How to Adjust Styles in a Regular Stylesheet
Before we use a cell content style in a table, let's make some simple adjustments in a regular stylesheet. Doing this will help us more clearly see what happens when you work inside a table.
-
In the Content Explorer, expand Resources > Stylesheets. Then double-click Styles.css.
-
On the left side of the local toolbar in the Stylesheet Editor, select Table Styles.
-
Select the td style, and set the font-size property to 10pt.
-
Change the filter to show Paragraph Styles, and set the p style to a font-size of 18pt.
- Click
to save your work.
- Open the Famous-Austin-Folks.htm topic.
-
Place your cursor at the end of Ben Crenshaw and press ENTER. Notice the much larger font size. This happened because each cell of a table uses the <td> tag initially to hold content, and the stylesheet is set to display that content at 10 pt. However, each cell can have only one <td> tag, so as soon as you press ENTER, Flare puts the content inside <p> tags, which are nested within the <td> tag. And because you set the p style at 18 pt, the text is much larger than the text in the rest of the table, where there are not yet <p> tags.
- Click
to undo your changes.
How to Apply a Cell Content Style
One way to get around the dilemma from the previous set of steps is to use a cell content style for your tables.
- Go back to the Styles.css stylesheet.
-
On the left side of the Stylesheet Editor, expand the p style, and under it select the table-text class. Then set the color property to blue.
- Click
to save your work.
- From the Content Explorer, expand TableStyles and double-click Alternate-Column-Color.css.
- In the TableStyle Editor, select the Rows tab. Notice that this stylesheet only has one row pattern (i.e., one row in the grid at the top of the editor), which means you only have to set the cell content style once. If you had more row patterns, you would need to set the style on each of them.
-
Scroll down in the field portion of the editor to the Cell Content Style field. In the Tag field select p, and in the Class field select table-text.
Note If you were to open the Alternate-Row-Color.css table stylesheet, you would see that the same cell content style has already been set for both of the row patterns.
- Click
to save your work.
- Go back to the Famous-Austin-Folks.htm topic.
-
Insert a new table in the topic, associating the Alternate-Column-Color.css stylesheet with it when you do. Then once the table is inserted, type some text in the cells. Notice that each cell of the regular rows already has the p.table-text class in it, and the font is therefore blue.
- Click
repeatedly until the new table is removed.
-
Notice that the existing table still has text without the blue color. You can update an existing table to use that cell content style. First, select all of the regular body cells in the table.
-
In the Table ribbon, click Cell Content Style.
- Scroll down in the dialog and select p.table-text. Then click OK.
- Click off the table and notice that all of the cell text is blue, even if you press ENTER after one of the names and type more text.
How to Use an Advanced Selector to Control Table Cell Content
- In the Famous-Austin-Folks.htm topic, click
repeatedly until the blue text is removed from the table.
-
Open the Alternate-Column-Color.css and Alternate-Row-Color.css stylesheets, and on the Rows tab remove the values in the Cell Content Style fields (i.e., you can delete the class from the second field and set the first field to (default)). Remember, in the Alternate-Row-Color.css stylesheet, you need to do this for each of the row patterns on that tab (i.e., select the first row pattern and remove the cell content style, then select the second row and remove the cell content style from it as well).
- Click
to save all files.
- Open the Styles.css stylesheet.
- On the left side of the Stylesheet Editor, filter for Table Styles.
-
Select the td style. Then set the color to green and the font-size to 12pt.
This will automatically use those values in all regular body cells of your tables. But what happens if you press ENTER at the end of text, creating <p> tags withing the <td> tag? That's what we'll take care of next by creating an advanced selector.
- In the local toolbar of the Stylesheet Editor, click Add Selector.
-
In the dialog, click in the HTML Element field and enter td (if it isn't already there). Then click the Advanced Options down arrow to show more fields.
-
In the Advanced Selector field, add a space after td, then type p.
This is a special style where you are telling Flare that when it finds a <p> tag within a <td> tag, you want it to look a certain way.
- Click OK.
-
Filter the Stylesheet Editor to show All Styles, and at the top of the list of styles, expand (Complex Selectors).
-
Under (Complex Selectors), scroll down and select td p. Then set its color to green and its font-size to 12pt.
- Click
to save your work.
- Go back to the Famous-Austin-Folks.htm topic, and notice that the table text is now green and 12 pt. Click after any of the names and press ENTER to create <p> tags and type more content. That text looks the same—green and 12 pt.
- Click
to save your work.
Note For most projects, using an advanced selector in a regular stylesheet is probably the best method to control the look of table cell content. Just use it with caution because it will affect all paragraph tags in all tables. If you want to have a different default look for paragraph content depending on the table, it might be better to use the cell content style.