Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Set table column width via Markdown

I have a project using Slate, which allows using table markup in the following format.

Name | Value
-------|-------------------
`Value-One` | Long explanation
`Value-Two` | Long explanation
`etc` | Long explanation

My problem is that the first column is rendered too narrow, and is wrapping the content (i.e. breaking the code values onto two lines) rather than displaying it on a single line. My preference is that the first column be wide enough to display the name/key fully, and then the second column can take up the rest of the available space.

My question is if it is possible (and therefore, how) to set the column width via markup, or at least add a class to the table via markup (so that I can style a particular table via CSS). Or is there a better approach to this? I'd prefer not to have to write out the table in full HTML (which would be a last resort option).

Answer*

Draft saved
Draft discarded
Cancel
7
  • 5
    @Pawel's answer is clever, but this answer is the correct one. I've just wasted 30 minutes of my life trying to get something that looks decent in a "Markdown Table", and it's hellish work. Commented Apr 24, 2018 at 12:44
  • 2
    @Seamus fair point. I think the best way to do it, if you’re using Kramdown, is to add a custom class markup with {:.foo}. about.gitlab.com/handbook/product/technical-writing/… Commented Apr 24, 2018 at 12:52
  • That's an amazingly useful website, thanks! And so is kramdown! And here's a really helpful cheat sheet when only the HTML-ized table will do Commented Apr 27, 2018 at 2:32
  • This lets you style the table but doesn't let you set the column width, other than equal column widths. Unless I'm missing a CSS property. We have table-layout: fixed for even widths – is there a way to set individual column widths? Commented Jun 1, 2021 at 21:21
  • 1
    You should have explained where to place the css. Commented Sep 28, 2021 at 7:16

AltStyle によって変換されたページ (->オリジナル) /