1

I have this table,

|   A |   B |   C |
|-----+-----+-----|
| 123 | 123 | 123 |
|-----+-----+-----|
|   4 |   5 |   5 |
|-----+-----+-----|
|   3 |   2 |   1 |
|-----+-----+-----|
|     |     |     |

and I would like the horizontal lines between rows to show when published: they show up on PDF export, but not on HTML export. Do you know why?

9
  • Please provide more information about what you're doing. Don't expect readers to just follow a link to a bunch of code. State your question clearly and succinctly, saying what you tried etc. Thx.
    – Drew
    Feb 18, 2022 at 17:27
  • I want to have horizontal lines between rows. I put the horizontal lines as shown on the sample (first three rows above) but when I publish I don't see the horizontal lines. What other information do I need to supply?
    – zeynel
    Feb 18, 2022 at 17:39
  • 1
    Published to pdf or html? Feb 18, 2022 at 18:47
  • 1
    Since there are dozens of ways to export an org file to some other format, it is often best to dive into the documentation and even the source code for the specific export method you are using and figure out how it can be changed to do what you want. For example, if you are exporting to HTML then there is probably an option to specify a custom style sheet. You could use that and then write a stylesheet which adds in the cell borders that you prefer.
    – db48x
    Feb 18, 2022 at 19:07
  • @FranBurstall I publish to html.
    – zeynel
    Feb 18, 2022 at 19:28

1 Answer 1

2

One option is to add CSS within your org file, which will also avoid having to insert a hline between each row in the table. Table attributes can be customized further, but to get horizontal borders for all rows the following could be used:

#+HTML_HEAD: <style type="text/css">
#+HTML_HEAD: tr {border-bottom: 1px solid;}
#+HTML_HEAD: </style>
|   A |   B |   C |
|-----+-----+-----|
| 123 | 123 | 123 |
|   4 |   5 |   5 |
|   3 |   2 |   1 |
|     |     |     |

As mentioned it the org manual, this will override any settings from org-html-table-default-attributes.


To add borders for only certain rows, the CSS can be modified to use nth-child. For example, to add a border to only the first 3 rows:

#+HTML_HEAD: <style type="text/css">
#+HTML_HEAD: tr:nth-child(-n+3) {border-bottom: 3px solid;}
#+HTML_HEAD: </style>
3
  • That will work (well, I think it will work, but I haven't tried it out) if you want borders after every row, but not if you want them after some rows only (again, I haven't tried it out, so that's what I think is the case).
    – NickD
    Feb 23, 2022 at 17:39
  • Yea that's correct, you would have to modify the CSS to use the nth-child and customize it from there. For example tr:nth-child(-n+3) {border-bottom: 3px solid;} to add a bottom border for only the first 3 rows.
    – c_48
    Feb 23, 2022 at 18:05
  • @c_48 Thanks! That works great.
    – zeynel
    Feb 23, 2022 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.