Custom Styles in Markdown
23 March 2021
Updated: 03 September 2023
When working with markdown it can often be useful to be able to style elements using custom CSS
We can accomplish this by including a style
tag. An example to illustrate this is changing the way a table renders in a specific document by changing the style of table rows to be striped, you would include the following CSS:
If the platform you’re displaying the HTML in already has the styles included then you may need to add !important
to override in the CSS:
my-sample-doc.md
Note that depending on your markdown renderer the embeded style tags may be removed, you’ll have to look at your specific renderer/converter/platform to see whether this works for you
With the converter I’m using, showdown.js
, this is how the table above looks (with !important
included to override my current table styles):
Col 1 | Col 2 | Col 3 |
---|---|---|
A | B | C |
1 | 2 | 3 |
A1 | B2 | C3 |