I'm writing a Github README.md file, and i have diferent tables. The contents are different, so table width is different too.
I want, at least the first column to be of fixed width, so i tried adding this before all the tables in the Markdown file:
<style>td:nth-child(odd){width:200px}</style>
Surprisingly that is working in my editor preview, but when committed to github, the text appears with the style tags stripped, and no style is applied.
My questions is if it's possible on github, and id it is, how do i do it.
Add tags to your markdown files You add tags by defining them in the frontmatter of your Markdown file. The frontmatter is the area at the top surrounded by dashes that includes post data like the title and date.
Markdown does have support for inline HTML, therefore you can add your own formatting inline using CSS or other HTML attributes, however this moves away from the quick markdown flavor.
Unfortunately you cannot use CSS in GitHub markdown as it is a part of the sanitization process. The HTML is sanitized, aggressively removing things that could harm you and your kin—such as script tags, inline-styles, and class or id attributes.
The <style> element must be included inside the <head> of the document. In general, it is better to put your styles in external stylesheets and apply them using <link> elements.
Just tested it myself.
<style> #foo {color: red} </style> <p id="foo">foo</p> <p style="color: blue">bar</p>
The above rendered to:
#foo {color: red} <p>foo</p> <p>bar</p>
GitHub strips style tags and attributes preventing you from changing the style on their pages. This is probably for security reasons. If you could inject css into GitHub pages, you could easily launch a phishing attack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With