Applying style="text-align: center;" to col attribute does seem to work

Grant Hogarth January 9, 2019

Is this not supported?  Trying to avoid the code bloat of applying this style string to a lot of cells in a table.

1 answer

1 accepted

0 votes
Answer accepted
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2019

You tried just highlighting the column(s) and clicking the center align button in the editor ribbon?

Grant Hogarth January 10, 2019

Yes.  That just throws in a style="text-align: center;" into every highlighted cell.  The opposite of what I was looking for. <wry smile>

Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2019

You said you wanted to add center aligned to the a column attribute. So I am a confused as to what you are wanting to do.

Grant Hogarth January 10, 2019

I want to *only* have the alignment value in the <col> section, rather than overrides for every cell in the table.
DESIRED:
<table>
     <colgroup>
          <col style="width: 246.0px; text-align: right;"/>
          <col style="width: 84.0px; text-align: center;"/>
          <col style="width: 86.0px; text-align: center;"/>
          <col style="width: 87.0px; text-align: center;"/>
     </colgroup>
     <tbody>
          <tr>
               <th>ITEM</th>
               <th>Status</th>
               <th>Number</th>
               <th>Group</th>
          </tr>
          <tr>
               <td>ITEM</td>
               <td>Status</td>
               <td>Number</td>
               <td>Group</td>
          </tr>
     <tbody>
<table>

(For about thirty-plus rows.)
----------------------------------
Currently I get this:
<table>
     <colgroup> 
          <col style="width: 246.0p"/> 
          <col style="width: 84.0px"/> 
          <col style="width: 86.0px"/> 
          <col style="width: 87.0px;"/>
     </colgroup>
     <tbody>
          <tr>
               <th style="text-align: right;">ITEM</th>
               <th style="text-align: center;">Status</th>
               <th style="text-align: center;">Number</th>
               <th style="text-align: center;">Group</th>
          </tr>
          <tr>
               <td style="text-align: right;">ITEM</td>
               <td style="text-align: center;">Status</td>
               <td style="text-align: center;">Number</td>
               <td style="text-align: center;">Group</td>
          </tr>
     <tbody>
<table>

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2019

You are correct that this is not how the editor works. There is no way to make it do what you are asking. You could work around it with good ol' CSS like below, but as for having the editor do it that unfortunately is a no go.

table tbody tr :nth-child(2),table tbody tr :nth-child(3),table tbody tr :nth-child(4){text-align: center;}
Grant Hogarth January 10, 2019

Ah well. :(
If it's not a defect, it's something for the wish list, as it makes the page code a lot smaller.
It is valid HTML!  :-)

Thank you

Grant

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events