Get underlined text with Markdown
RubyMarkdownUnderlineBlueclothRuby Problem Overview
I am using BlueCloth as a Markdown library for Ruby, and I can't find any syntax for getting a text underlined. What is it?
Ruby Solutions
Solution 1 - Ruby
In GitHub markdown <ins>
text</ins>
works just fine.
Solution 2 - Ruby
Markdown doesn't have a defined syntax to underline text.
I guess this is because underlined text is hard to read, and that it's usually used for hyperlinks.
Solution 3 - Ruby
Another reason is that <u>
tags are deprecated in XHTML and HTML5, so it would need to produce something like <span style="text-decoration:underline">this</span>
. (IMHO, if <u>
is deprecated, so should be <b>
and <i>
.) Note that Markdown produces <strong>
and <em>
instead of <b>
and <i>
, respectively, which explains the purpose of the text therein instead of its formatting. Formatting should be handled by stylesheets.
Update:
The <u>
element is no longer deprecated in HTML5.
Solution 4 - Ruby
The simple <u>some text</u>
should work for you.
Solution 5 - Ruby
You can wrote **_bold and italic_**
and re-style it to underlined text, like this:
strong>em,
em>strong,
b>i,
i>b {
font-style:normal;
font-weight:normal;
text-decoration:underline;
}
Solution 6 - Ruby
In Jupyter Notebooks you can use Markdown in the following way for underlined text. This is similar to HTML5: (<u>
and </u>
).
<u>Underlined Words Here</u>
Solution 7 - Ruby
(this answer rewritten since the downvotes)
<u>
tag (recommended) or the <ins>
tag inside your markdown for this.
Just use the HTML The HTML tag <ins>
is the HTML "insert tag", and is usually displayed as underlined. Hence, you can use it for underlining, as @BlackMagic recommends in his answer here. It is the opposite of the <del>
delete tag.
But, I'd prefer and I recommend to just use the HTML <u>
underline tag, since that's exactly what it's for:
<u>this is underlined text in HTML or markdown, which accepts HTML</u>
@zed_0xff also recommends using the <u>
tag in his answer here.
You can try it out live online here: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_u.
Can I use CSS too?
It depends. On your custom Jekyll website? Sure. In GitHub readmes and other GitHub markdown files? No!
HTML tags work fine in GitHub readmes too, because GitHub accepts HTML tags just fine. BUT, custom CSS in GitHub does NOT work since GitHub blocks and rejects all custom CSS you may try to add. I talk about this in my other answer here: https://stackoverflow.com/questions/12090472/github-readme-md-center-image/62383408#62383408.
Solution 8 - Ruby
Both <ins>text</ins>
and <span style="text-decoration:underline">text</span>
work perfectly in Joplin, although I agree with @nfm that underlined text looks like a link and can be misleading in Markdown.
Solution 9 - Ruby
that is NOT best practice because is a link but you can do this in some libraries
[example link with #](#)
but for example, here on stackoverflow doesn't work