It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I set the width of columns in my tables?

Timothee Timothee Dec 19, 2011

We recently switched to Confluence 4.0 and I lost my wiki markup editor :(

I am trying to change the width proportions of the columns in my table. Apparently I should be typing some {table-plus } type of macros, but I can't find a clear piece of documentation for it.

10 answers

1 accepted

4 votes
Answer accepted
Andrew Frayling Dec 20, 2011

Starting again :) If you have admin rights you could enable the {html} macro in Confluence Admin -> Plugins -> Confluence HTML Macros and then enter something along the lines of:

{html}
<table border="1" width="100%">
<tr>
<td width="33%">One</td>
<td width="33%">Two</td>
<td width="33%">Three</td>
</tr>
</table>
{html}

in the editor.

Alternatively, the "Table Plugin" plugin that provides the {table-plus} macro is now 4.x compatible so you could install that via the Universal Plugin manager under Confluence Admin or download from https://plugins.atlassian.com/plugin/details/197?versionId=43351 If you use the {table-plus} macro you should be able to use:

{table-plus:border=1|width=400px|columnAttributes:width=100px}
||One||Two||Three||Four||
|foo|bar|foo|bar|
{table-plus}

to set column widths. More examples of the formatting for {table-plus} are available at https://studio.plugins.atlassian.com/wiki/display/TBL/Table-plus+macro

Hope that helps,

Andrew.

Timothee Timothee Dec 20, 2011

Thanks .. I've asked our IT to look into enabling those..

Rachel Dunlop Jan 20, 2013

How do I do this in Confluence 4+? I tried adding "width=100px" to the Column Attributes field but it didn't work?

9 votes
Kelly Schoenhofen Mar 03, 2015

I just found the method that Burke Mamlin put out here - https://jira.atlassian.com/browse/CONF-3393 - he wrote a snippet of html/javascript that you insert into Confluence Administration > Custom HTML > At the end of HEAD, then you can set column widths by prefixing column names with "200|" for 200 pixels, or "20%|" for 20%, et al. So far it's been dreamy. Thank you @Burke Mamlin (not sure if I got the right one, there's 4). 

Edit: apparently the original version is hard to find now. Here's the latest version we're using. It's been less useful as time goes by though - it works best for very specific situations, and it's definitely not for everyone. We've had users remove the values from tables when editing pages because they didn't know why they were there and were just trying to clean up/help. They also didn't notice when the tables re-sized themselves afterwards as well :/

Put this in your custom html HEAD:

<script type="text/javascript">
<!--
AJS.$(document).ready(function() {
  AJS.$('#content .wiki-content table').find('tr:first > th,tr:first > td').each(function() {
    var match = /^\s*((\d+)(px|%)?)\s*\|(.*)/.exec(this.textContent)
    if (match != null) {
      this.width = match[1]
      this.textContent = match[4]
    }
  })
})
-->
</script>
Burke Mamlin Mar 03, 2015

You're welcome! Hope it works well for you. If it does, pay it forward by giving someone a hug today. :-)

Tim Mohrbach May 28, 2015

this works like a charm!

Konstantin Korostin Oct 06, 2015

Where do we find a copy of this snippet, CONF-3393 does not seem to have it. Could you please add it to this comment.

Kelly Schoenhofen Oct 06, 2015

Done, I edited my original answer.

Christof Hurst Jul 06, 2016

Instead of

this.textContent = match[4]

it ist better to use

this.innerHTML = this.innerHTML.replace(match[1]+"|", "")

So all formatting will be preserved.

Andy "Krazy" Glew Sep 13, 2016

You do realize that requiring administrator privileges to change the width of a column is pretty f**g broken, don't you?

Ditto having to use a macro, different than the existing.

I have existing tables, prepared with Confluence's default not-quite-WYSIWYG table editing facilities. Many of them. Their column widths are broken.  I would like to fix them, not start over.

Dmitry Ree Dec 26, 2017

if you prefix columns names then content cannot be retrieved using page properties report

4 votes
Steven Behnke Community Leader Apr 28, 2017

It's funny that this question is on the top answers, but this information is massively outdated. You can now drag columns to set width in the editor.

Pablo Serra Apr 25, 2018

Hi Steve, is it available on version 5.9.4? I can't drag columns as described by you.

3 votes
Rand McKinney Dec 03, 2013

One simple but kind of hacky way is to insert an invisible "div" tag into a cell for which you want to specify the width. Use the free Adaptavist div macro and in the style parameter, specify width: 100px; (or whatever width you want to set). You'll have to do this for each column you want to size, but it's pretty easy and you can still use the visual table editor.

Vitalii Zurian Apr 25, 2015

Thanks!

1 vote
Sherif Mansour Atlassian Team Aug 23, 2013

We have an open feature request for this, by the way https://jira.atlassian.com/browse/CONF-3393

0 votes
John Masson Dec 19, 2011

Hi Timothee,

The Table Plus Macro doesn't support Confluence 4.0, so for now you'll need to insert the markup for it using the dialog accessble from 'Inert' > 'Wiki markup'.

Thanks,
John

Timothee Timothee Dec 20, 2011

I haven't found what the markup should look like though?

0 votes
Andrew Frayling Dec 20, 2011

Hi Timothee,

I don't think you can set column widths for tables without the {table-plus} macro and it doesn't look like this feature is on the native roadmap according to https://jira.atlassian.com/browse/CONF-1398

One way around it is to use {section} and {column} macros, e.g.

{section:border=true}
 
{column:width=30%}
Text for this column goes here. This is  the smaller column with a width of only 30%.
{column}
 
{column:width=70%}
Text for this column goes here. This is  the larger column with a width of 70%.
{column}
 
{section}
Not sure if that would work for you?
Andrew.

Timothee Timothee Dec 20, 2011

Ouch .. ok .. I see how that example works. It's pretty much impossible to edit or maintain complex tables that way though. Not that table support was particularly advanced in earlier versions, but it seems it took a bit of a dive :(

Any way to seamlessly embed excel spreadsheets maybe? If not I may just take a screenshot and attach. But it's going to make PDF exports less useful.

0 votes
Tim Durden Jun 26, 2015

As a very ugly workaround, try copying and pasting a few whitespace characters / line breaks.

Steffen Heller Dec 17, 2015

...or use a spacer gif.

0 votes
Jeffrey Pfeifer Aug 17, 2018 • edited

The simplest solution without playing around with the markup...

On the top row of any column you want to have a specific width, insert a DIV macro/plugin in that cell.  On the DIV add a style for the width in the div settings page, for example width: 400px.  The div expansion, will force the table column to that size. 

0 votes
BeanbasketB Oct 01, 2018

.issue-table > tbody > tr > td {
width:auto;

}
.issue-table > thead > tr > th {
width:auto;
}

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

873 views 0 19
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you