Markdown is a lightweight markup language that allows users to create formatted text using plain text syntax. One common formatting option is underlining text, which can be achieved using HTML tags within Markdown. In this tutorial, we will explore how to underline text in Markdown.
Using the HTML <u>
Tag
The most straightforward way to underline text in Markdown is by using the HTML <u>
tag. This tag is specifically designed for underlining text and is widely supported across different Markdown parsers and platforms.
Example:
<u>this is underlined text</u>
This will render as: this is underlined text
Using the HTML <ins>
Tag
Another option for underlining text in Markdown is by using the HTML <ins>
tag. This tag is typically used to indicate inserted text and is usually displayed as underlined.
Example:
<ins>this is underlined text</ins>
This will render as: this is underlined text
Note that while both tags can be used for underlining text, the <u>
tag is more semantically correct and recommended for this purpose.
Underlining Headings in Markdown
When it comes to underlining headings in Markdown, the approach may vary depending on the platform. On most platforms, using the <u>
tag within a heading will work as expected. However, on GitHub, you need to use the <ins>
tag instead of <u>
for underlined headings.
Example:
# <ins>Underlined Heading 1</ins>
## <ins>Underlined Heading 2</ins>
### <ins>Underlined Heading 3</ins>
This will render as underlined headings on GitHub.
Using CSS for Underlining Text
While HTML tags are the primary way to underline text in Markdown, you can also use CSS styles to achieve this effect. However, keep in mind that custom CSS may not work on all platforms, such as GitHub, which blocks and rejects custom CSS.
If you have control over the CSS styling of your Markdown content, you can use the text-decoration
property to underline text.
.underlined {
text-decoration: underline;
}
Then, in your Markdown:
<span class="underlined">this is underlined text</span>
This will render as underlined text, provided that the CSS styling is applied correctly.
In conclusion, underlining text in Markdown can be achieved using HTML tags, specifically the <u>
and <ins>
tags. While custom CSS can also be used for this purpose, it may not work on all platforms.