Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Center tables in HTML #9165

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Center tables in HTML #9165

wants to merge 1 commit into from

Conversation

remysucre
Copy link

Modern computer screens are quite wide, so a center-aligned table looks much better than a left-aligned one. For example, compare the two below. This can be achieved by simplifying the CSS template as done in this PR.

Screenshot 2023-11-01 at 8 49 41 PM Screenshot 2023-11-01 at 8 49 33 PM

@jgm
Copy link
Owner

jgm commented Nov 2, 2023

This should be tested with a much wider selection of tables, including tables with relative column widths (e.g. some of the later tables in test/tables.native or test/tables-rstsubset.native). There may be reasons for the things that were deleted.
(cc @mb21)

@mb21
Copy link
Collaborator

mb21 commented Nov 2, 2023

Modern computer screens are quite wide

yes but pandoc's default CSS actually constrains the text width to 36em (80 characters or so).

a center-aligned table looks much better than a left-aligned one.

for a very small table like the one in the screenshot, I agree. but for even just a bit wider tables, I think it's less clear and may be subjective.

Either way, some things to look out for when changing this is to test with big (very wide) tables, and test on mobile phones: the width: 100% is there so that the table is horizontally scrollable if it's wider than the screen.

@remysucre
Copy link
Author

the table is horizontally scrollable if it's wider than the screen.

I see. I couldn't come up with a way to both center narrow tables and make wide tables scroll. IMO the default template should optimize for tables that are not too wide, and people should provide custom styles for wide tables. After all that's the default behavior for tables in CSS.

I do agree this is a subjective issue so feel free to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants