-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Improve style for <table> with <caption> #7889
Comments
I won't get into specific issues with the referenced extension unless you bring up specific points, but you seem to be highlighting that you don't like that the table is wrapped with Let me address some confusion. If you put the caption directly under the table, it is inside the table, so any border on the table is going to be around the caption. This a sane and reasonable approach. If you do not like this, I would strongly advise not placing the caption inside the table. That is why |
Thanks a lot for your reply.
I have to say that
Actually, I think directly applying a border around the entire From my observations, using the |
Thanks for reporting. So, this happens due to a hack we've had in place for 8 years, as we set the mkdocs-material/src/templates/assets/stylesheets/main/_typeset.scss Lines 455 to 457 in 3cc0a30
I'm not sure whether we still need this hack, because it's been such a long time ago, so issues might have been fixed, but digging into the changelog and related issues, I've found the following: We're in feature freeze right now, and since this is not a simple to fix bug, as it's hard to know the impact, we'll address this later, once we finish the foundational work we're currently working on. In the meantime, the following additional CSS should mitigate the issue, but it will revert the hack that we've got in place to normalize table styling: .md-typeset table:not([class]) {
display: table;
} |
In addition, I'm curious as to why Mkdocs-Material's Example: <table style="border:1px solid;">
<caption>Simple Table Caption</caption>
<tr> <th>foo</th> <th>bar</th> </tr>
<tr> <td>wawawa</td> <td>hahaha</td> </tr>
</table> I discovered that the Example: <table style="border:1px solid; display: inline-block;">
<caption>Simple Table Caption</caption>
<tr> <th>foo</th> <th>bar</th> </tr>
<tr> <td>wawawa</td> <td>hahaha</td> </tr>
</table> The suspicious code is here: mkdocs-material/src/templates/assets/stylesheets/main/_typeset.scss Lines 454 to 457 in 3cc0a30
I'm not entirely sure why there is such ... |
Or you know what, I wouldn't declare this a bug, actually, but rather a limitation of the current design. Thus, I'm marking this as a change request that is currently resolvable with customization. |
@cebarobot our comments overlapped timewise – yes, you're right, this is the property in question, see #7889 (comment) |
@squidfunk Thanks a lot for your reply. I really appreciate your help. |
@cebarobot Ah, I see now you were referring to |
@facelessuser No problem at all. I appreciate your help in this. |
Context
I'm attempting to add captions to tables in Markdown by embedding
<caption>
elements within<table>
elements, but the results don't appear as visually appealing as expected. The caption is displayed inside of the table border, and it seems that there is no stylesheet to handle this.For example, this is an simple HTML table:
The outcome of Mkdocs for Material looks not good.
This is not a problem about syntax of table caption. It's about the build-in CSS.
pymdownx.blocks.caption always generates
<figure>
and<figurecaption>
rather than<table>
and<caption>
, so it is unrelated with this issue.Description
Improve the stylesheet for
<table>
and<caption>
, to make sure caption is displayed outside of the table border.Related links
HTML reference:
Markdown extension for table caption:
Use Cases
<caption>
is a standard HTML element that specifies the caption (or title) of a table. Mkdocs-material should provide the appropriate stylesheet for it.Additionally, some Markdown extensions offer different syntaxes for adding captions to tables, all of which use
<caption>
in the generated HTML.Visuals
The expected style is as follows:
Before submitting
The text was updated successfully, but these errors were encountered: