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 can I set width of Confluence Cloud table columns using Confluence REST API? Edited

The below html is not working. text-align works but not width. Columns have equal widths.

<table>
<tr>
<th style="text-align: center; font-size: large; width: 5%;">
#
</th>
<th style="text-align: center; font-size: large; width: 10%;">
Number
</th>
<th style="text-align: center; font-size: large; width: 40%;">
Title
</th>
<th style="text-align: center; font-size: large; width: 10%;">
FDX
</th>
<th style="text-align: center; font-size: large; width: 10%;">
OFX
</th>
<th style="text-align: center; font-size: large; width: 10%;">
FIRE
</th>
</tr>
...

 

1 answer

1 accepted

2 votes
Answer accepted
Diego Atlassian Team Mar 20, 2020

Hello @Bruce Wilcox ! As I understand, you need to manually set the Table Column width via REST API.

Looking at your lines, I see that everything should be working, CSS/HTML wise. If we take a look at a 3x3 table created in Confluence, here is what the syntax looks like:

TableSyntax.jpg

Here is the table:

TableImage.jpg

With this in mind, we can apply the desired width to the <col> tag inside the <colgroup> tag. This element should support size in %.

Try to remove the width parameter from the style in your table headers<th> and move it to the <col> inside <colgroup>.

I hope this helps you out, Bruce! Looking forward to your reply.

Thank you very much, Diego.

I changed to the following and it works. 

<table>
<colgroup>
<col style="width: 36px;" />
<col style="width: 48px;" />
<col style="width: 480px;" />
<col style="width: 36px;" />
<col style="width: 36px;" />
<col style="width: 36px;" />
</colgroup>
<tr>

I find that (1) %'s do not work and (2) using pixels actually sets proportional not absolute widths.

I also find that xhtml is required. You must close empty tags with />.

Thank you again.

Like Diego likes this
Diego Atlassian Team Mar 20, 2020

Great to know that you were able to create the table, @Bruce Wilcox ! Also, thank you very much for sharing those tips here with the community.

Like Mandy Ross likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

5,345 views 4 6
Join discussion

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