How do I add a background color to a table row in the Confluence editor?

New to Confluence, and this seems like a very simple thing, but I can't figure out how to add a background color to table rows in the Confluence editor. Am I missing something obvious somewhere? It's easy to do for panel and other areas, so surely there must be some option I'm missing somewhere as adding color to tables seems like a base editing feature that should just be there.

8 answers

1 accepted

This feature is actually available since Confluence 4.3 (CONF-6482)

Slide 11 of this presentation offers a simple way to color table rows with the aid of a user macro : http://www.slideshare.net/GoAtlassian/a8-no-coding-necessary

My corporate firewall blocks that site. Can you summarize the slide?

<script type=text/javascript" defer="defer">

  jQuery(document).ready(function()

  {

    jQuery("tr:even").css("background-color", "#318db6");

    jQuery("tr:odd").css("background-color", "#f86a46");

  });

</script>

Colour and Other Formatting

To add colour and other formatting to your tables, you can use the Panel Macro within columns.
More table-formatting options may be available if your Confluence administrator has installed additional macros.

Source: Working with Tables

Hello I just tried to use the panel macro inside a tabel but the result I get doesn t look good. I am convinced I am doing something wrong just by adding the panel macro to a table cell... (seems the image upload is not working ...)

0 vote

We also have an open feature request for this that you might want to follow / vote on: https://jira.atlassian.com/browse/CONF-6482

Can you check the link. It says, "project does not Exist"

Joseph Clark Atlassian Team Sep 12, 2011

I've fixed the link.

Atlassian claims the ticket is resolved as of v4.3. I am using v5.3 (upgrading soon) and there is no color picker available. There are 5 pastels - not enough! We should be able to customize our tables without the panel hack, which leaves whitespace where it is not needed. What can be done to thoroughly resolve this issue? Why will Atlassian not add a color picker for background tables.

And while we are on this topic, why can we not add our own hex values to the text colors?

Here we are almost 2 years later and no update. Still only 5 pastel colours to choose from. What is stopping Atlassian from using hex values or a colour picker as Anna suggested. Having used other collaborative and content solutions, Confluence is extremely backwards in a large number of areas. Given the underhanded approach to add-on pricing, I'd at least expect the basics (content formatting, table column widths etc.) to be handled well. I don't want a bunch of hacks, add-ons or embedded code to make simple colour changes.

There is a table macro that you can use like as follows -

{table:style=border:1px dotted #ccc;}
{tr:style=text-align:center;background-color:silver;color:Indigo}
{th}Heading{th}
{tr:style=text-align:center;background-color:green;}
{td:align=left}data{td}{tr}
{table}

There is a simpler approach than Nikhil's solution that only needs the {html} macro but allows for the use of wiki tables if you have text in your cell. Put this in the cell contents of your wiki table (assuming you have the {html} macro enabled):

{html}<span style="background-color:lime"/>pass{html}
e.g.
|| Test Name|| Pass/Fail||
|Test 1 | {html}<span style="background-color:lime"/>pass{html}|
|Test 2 | {html}<span style="background-color:red"/>fail{html}|
|Test 3 | {html}<span style="background-color:yellow"/>error{html}|

For standardtables, I would choose the "panel" approach. It is build in out-of-the-box and easily readable and reproduceable for infrequent users.

HTML Macro has the security issues and the more macros/plugins you have, the more difficult the system is to maintain and teach.

Hello!

For conditional formatting in Confluence you may use CelesteCS Conditions for Confluence.

Assume you need to set a specific background color for some values on your table, for example, for 'Yes' make it light-green and for 'No' make it light-red. You just put your table into Conditional Rules Manager macro and add two Conditional Rule macros to specify rules of type 'Element Value Is Equal To', which is by default. In one of the rules you specify 'Value 1' = 'Yes' and 'Background color' = 'highlight-green' and in another one 'Value 1' = 'No' and 'Background color' = 'highlight-red'. That's it! The cells will be formatted appropriately.

As you see, it's very simple - just add a couple of macros and configure it properly. No need for doing it manually, writing user macros or use source code editors.

There are more than a dozen of conditional rule types supported. Plus, you may replace the text, not just to format it.

We are the CelesteCS Conditions for Confluence plugin vendor, so you may contact us directly if you have any additional questions or suggestions.

Thanks!

 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

1,263 views 23 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you