Is it possible to add an id or class to a (multi)markdown element?
For example a table, a paragraph or block of code?
I would like to style a table with css but non of following work:
[captionid][This is the caption, not the table id]
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
[captionid][This is the caption, not the table id]
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
[tablecaption](#tableid)
<div class="special_table">
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
</div>
Can't find anything else online..
I dont mean github or stackoverflow flavored markdown btw.
Many Markdown processors support custom IDs for headings — some Markdown processors automatically add them. Adding custom IDs allows you to link directly to headings and modify them with CSS. To add a custom heading ID, enclose the custom ID in curly braces on the same line as the heading.
No. But... No, Markdown's syntax can't. You can set ID values with Markdown Extra through.
For CSS purposes you could add an id to the previous element and then use a selector to alter the following element.
Markdown like this:
<div class="special_table"></div>
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
CSS like this:
div.special_table + table tr:nth-child(even) {background: #922}
You can add a custom class or id to an element by putting the class or id inside a curly bracket after the element like this: {#id .class}
For example:
[Read more](http://www.stackoverflow.com "read more"){#link-sf .btn-read-more}
will be rendered like below:
<a href="http://www.stackoverflow.com" title="read more" id="link-sf" class="btn-read-more">Read more</a>
You can refer to https://michelf.ca/projects/php-markdown/extra/#spe-attr
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