How can I underline text in Markdo开发者_高级运维wn?
In GitHub markdown <ins>
text</ins>
works just fine.
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.
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.
The simple <u>some text</u>
should work for you.
Just use the HTML <u>
tag (recommended) or the <ins>
tag inside your markdown for this.
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.
What about underlined headings on GitHub?
@NoChance left in the comments:
I guess the
<u>
does not work with#
, for example, let's say you have Header 3 and you want to make it bold and underline - what can one do?
In this case, for it to work on GitHub, you have to use <ins>
in place of <u>
.
Do this:
# <ins>Underlined Heading 1</ins>
## <ins>Underlined Heading 2</ins>
### <ins>Underlined Heading 3</ins>
#### <ins>Underlined Heading 4</ins>
<!-- etc. -->
That works on GitHub too! Sample output on GitHub:
Using <u>
in place of <ins>
there will work on most markdown viewers, but not on GitHub.
See a full demo and trial file in my eRCaGuy_hello_world repo here: eRCaGuy_hello_world/markdown/underline.md.
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: How do I center an image in the README.md file on GitHub?.
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;
}
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>
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.
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
example link with #
精彩评论