question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Table styling and alignment is wonky

See original GitHub issue

Subject of the issue

When you specify the alignment of a table in markdown syntax, the generated html is strange. It doesn’t respect the specified alignment, nor correctly get assigned style.

Your environment

  • OS: Windows 10

Packages

Env

  • yarn 1.21.1
  • node 12.14.1

Steps to reproduce

Using the Gatsby starter, place or replace the following mdx in src/pages/index.mdx

| Left | Centre | Right |
|:-----|:------:|------:|
| 1 | 2 | 3 |

navigate to localhost:8000/

Expected behaviour

Every component of the table should receive a style if nessisary, and alignment should be respected based on stated alignment.

<table class="css-somehash">
  <thead class="css-somehash">
    <tr class="css-somehash">
      <th align="left"   class="css-somehash">Left</th>
      <th align="center" class="css-somehash">Centre</th>
      <th align="right"  class="css-somehash">Right</th>
    </tr>
  </thead>
  <tbody class="css-somehash">
    <tr class="css-somehash">
      <td align="left"   class="css-somehash">1</td>
      <td align="center" class="css-somehash">2</td>
      <td align="right"  class="css-somehash">3</td>
    </tr>
  </tbody>
</table>

Actual behaviour

In versions prior to 1.5.5, the alignment was correct, but the css classes were absent on inner tags like tr and th,

<table class="css-0">
  <thead>
    <tr class="css-0">
      <th class="css-0">Left</th>
      <th class="css-0">Centre</th>
      <th class="css-0">right</th>
    </tr>
  </thead>
  <tbody>
    <tr class="css-0">
      <td class="css-0">1</td>
      <td class="css-0">2</td>
      <td class="css-0">3</td>
    </tr>
  </tbody>
</table>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Everspacecommented, Feb 4, 2020

Thank you. I will go over there and bother them.

1reaction
denu5commented, Feb 6, 2020

@ChristianMurphy thanks! actually just found the official way since I’m also using the theme-ui plugin, you can pass a style object with styles, which is the customized theme-ui provider I guess

style={{
    table: {
      width: '100%',
      borderCollapse: 'separate',
      borderSpacing: 0
    },
    th: {
      textAlign: 'left',
      borderBottomStyle: 'solid'
    },
    td: {
      textAlign: 'left',
      borderBottomStyle: 'solid'
    },
  }}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem: Cell alignment in a table - Microsoft Community
I am having a puzzling problem in a table. Using Cell Alignment I want to line up a line of text and a...
Read more >
Alignment Issue With Table (Responsive) - Litmus
Hi there,. I have a problem with 3 tables alignment. Here is my source code : <table class="inner" align="center" border="0" cellpadding="0" ...
Read more >
Tablesaw alignment styling takes precedence over Drupal ...
Problem/Motivation When the module is enabled and Stack mode is selected in configuration, the alignment settings of all tables are broken ...
Read more >
CSS Table alignment issue - Stack Overflow
I'm working on a table here using a combination of Bootstrap + manual CSS. ... For some reason the second table is aligned...
Read more >
Fine tuning the Table of Contents (TOC) alignment - YouTube
... items in your Table of Contents is misbehaving (if items are misaligned), it's a simple case of fine-tuning the TOC styles to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found