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*

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
4
  • 2
    This is the most elegant (no "invisible" images), and allows using % of total width. Nice! Commented Apr 21, 2020 at 21:31
  • 2
    But it seems like it will work for all the tables within an article (global). How can I apply different rules to different tables within one article (local)? Commented May 11, 2020 at 10:17
  • 1
    @sun0727 add a css class for it , ref stackoverflow.com/a/36215330/12073333 Commented May 13, 2020 at 1:11
  • I like this option more than the excepted answer for a one-off solution, although the accepted answer is extensible to other pages in your site. Commented Jun 8, 2024 at 14:39

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