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?
9 Answers
In GitHub markdown <ins>text</ins> works just fine.
- 21,685
- 24
- 196
- 332
- 3,292
- 1
- 18
- 14
-
8And in BitBucket too... (as well as text) – рüффп Jul 09 '20 at 08:49
-
3text doesn't work, but I never heard about tag lol, - it's seems because it's so unpopular, it still works (normally it's not very good to underline text) – Jerry Green Nov 04 '20 at 06:39
-
6In case anyone wanted to know `text` works fine in Jupyter notebooks too – Hawklaz Nov 08 '20 at 09:04
-
2I prefer ``. Here's a little more info: https://stackoverflow.com/a/66595330/4561887. – Gabriel Staples Mar 12 '21 at 06:44
-
Wow, the usability of markdown is great! [the poster says after looking for this info for days ... only to find a per-site answer ... intuitiveness and standardization being the definition of usability.] – zylstra Apr 29 '21 at 17:03
-
From [Mardown specs](https://daringfireball.net/projects/markdown/syntax#html): _For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags._ Specs are clear. Implementations vary... – Pierre Jun 16 '21 at 21:26
-
Also works in obsidian – jason Feb 28 '22 at 23:01
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.
- 18,339
- 14
- 59
- 88
-
"it's usually used for hyperlinks" says someone who probably enters links in markdown input boxes daily. – zylstra Apr 29 '21 at 16:56
-
2@Shredder2794: That's not how markdown is supposed to work. If you find yourself frequently having to write html code inside of markdown, you're probably not using it for the purpose it was meant to be used for. There are edge cases which require html tags and code other than markdown, but again those are edge cases. – Saturn K Sep 22 '21 at 20:51
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.
- 5,376
- 1
- 28
- 43
-
1
-
5@TobyBartels I'm not sure what you mean. "The element represents a span of text with an unarticulated, though explicitly rendered, non-textual annotation," whereas "the element represents an addition to the document." These are two semantically very different things. – jordanbtucker Nov 21 '13 at 00:44
-
6I mean that `` is not particularly a semantic tag at all, while `` is. Yet they are traditionally rendered in the same way. So `` is the semantic analogue of ``, while `` is the syntactic analogue of ``. Well, even if you don't like how I describe it, the point is that we have this analogy: `` : `` :: `` : `` :: `` : ``. (Also `
` : `– Toby Bartels Nov 21 '13 at 02:10`.) -
4@TobyBartels Ah, I misinterpreted you. I thought you were saying that and were semantically equivalent. The HTML5 spec has actually given semantic meanings to , , , and
that are different from their stylistically similar counterparts, but I see your point.– jordanbtucker Nov 21 '13 at 16:42
The simple <u>some text</u> should work for you.
- 30,030
- 21
- 100
- 124
- 31,180
- 7
- 50
- 72
-
I forgot to say that I use the :escape_html option so an user cannot destroy my layout or inject some javascripts. I render that way: `BlueCloth.new("foo", :escape_html => true).to_html`. That will escape the tag. – Peter Jun 09 '10 at 06:37
-
then you cannot have a underlined text. only to manually unescape produced `<u>` and `</u>` back to `` and `` – zed_0xff Jun 09 '10 at 06:54
-
8
-
4I agree: Why is that? Markdown (or any language like it) should make it *easier* to do common things that people want to do (like underline words), not harder or impossible. – Tyler Rick Sep 27 '11 at 20:37
-
2It's probably because shouldn't be used for simple underlining in HTML5 any longer ... – s.krueger Jul 03 '13 at 09:18
-
2@s.krueger Please read https://html.spec.whatwg.org/multipage/semantics.html#the-u-element. `` can be used for underlining, but is discouraged "where it could be confused for a hyperlink." – jordanbtucker Oct 08 '14 at 18:02
-
@jordanbtucker "The u element represents a span of text with an unarticulated, [...] non-textual annotation, such as labeling the text as being a proper name in Chinese text [...] or labeling the text as being misspelt." Doesn't sound to me as the usual case people here are discussing about :) – s.krueger Oct 08 '14 at 22:16
-
1@s.krueger I think the terms "unarticulated" and "explicitly rendered" are exactly the cases discussed here. When you can't rely on CSS, which can be the case with Markdown, `` is your best option for explicitly rendered underlining. Of course, more semantic elements should be used when possible. – jordanbtucker Oct 09 '14 at 02:31
-
1@Peter: may be because `` and `` are available in HTML5 for italic and bold respectively, but there is no semantic markup for underline – ns. Jun 30 '15 at 11:09
-
1
-
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;
}
- 1,124
- 17
- 33
-
14-1 This seems like a hack to me, I'd prefer to understand the motivation behind it, underlines exclusion won't be an accident. – Phil Hauser Sep 05 '16 at 07:12
-
7
-
2
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>
- 8,409
- 9
- 67
- 106
- 724
- 8
- 13
(this answer rewritten since the downvotes)
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.
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: GitHub README.md center image.
- 22,024
- 5
- 133
- 166
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.
- 8,409
- 9
- 67
- 106
- 1,042
- 1
- 7
- 24
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 #
- 69
- 1
- 2