Skip to main content

HTML <rt> Tag

The <rt> element is an HTML tag used to define a ruby text component in a ruby annotation (<ruby>) element. Ruby annotations are small, inline text explanations that are used to provide pronunciation or interpretation of East Asian characters.

They are often used in conjunction with the <ruby> and <rp> elements to provide proper formatting and pronunciation guidance for East Asian languages.

The <rt> element should be used to contain the ruby text component. It should be used within a <ruby> element, and can be used alongside the <rp> element to provide parentheses around the ruby text for browsers that do not support ruby annotations.

Here is an example of the basic structure of a ruby annotation using the <ruby>, <rt>, and <rp> elements:

<ruby>
    漢 <rp>(</rp><rt>hàn</rt><rp>)</rp>
    字 <rp>(</rp><rt>zì</rt><rp>)</rp>
</ruby>

In this example, the <ruby> element contains the characters "漢字", which are the characters being annotated. The <rp> elements provide parentheses around the ruby text, which is the pronunciation of the characters contained in the <rt> elements. In this case, the ruby text for the first character is "kan", and the ruby text for the second character is "ji".

Ruby annotations can also be used to provide interpretation or translation for the characters, rather than just pronunciation. Here is an example of a ruby annotation providing both pronunciation and translation:

(hàn)() (Chinese characters)
<ruby>
    漢 <rp>(</rp><rt>kan</rt><rp>)</rp>
    字 <rp>(</rp><rt>ji</rt><rp>)</rp>
    <rp>(</rp><rt>Chinese characters</rt><rp>)</rp>
</ruby>

In this example, the first two <rt> elements provide the pronunciation for the characters "漢字", and the third <rt> element provides a translation of the characters as "Chinese characters".

It's important to note that ruby annotations are not widely supported in all browsers, so it's important to use the <rp> elements to provide fallback content for browsers that do not support ruby annotations.