HTML <rt> tag
The <rt> tag is used to provide the text component of a ruby annotation.
It helps in explaining translation or pronunciation for East Asian typography.
It should be used inside the <ruby> element.
Type: Inline Element
Example of <rt> tag
<ruby> 印度 <rt>India</rt> </ruby>
<rt> tag is introduced in HTML5.
Full code example
<!DOCTYPE html> <html> <head> </head> <body> <ruby> 印度 <rt>India</rt> and 美国 <rt>America</rt> are the two powerful military countries. </ruby> </body> </html>
Output on the browser
印度 and
美国
are the two powerful military countries.
Supported Browsers
| Tag | Chrome | Internet Explorer | Firefox | Safari | Opera Mini |
|---|---|---|---|---|---|
| <rt> | 5.0 or higher | 5.5 or higher | 38.0 or higher | 5.0 or higher | 15.0 or higher |
Ruby annotations are used to show the pronunciation or reading of text, mainly in East Asian languages.
How do we create ruby annotations using the <ruby>, <rt>, and <rp> tags?
- To create ruby annotations, all the elements should be contained within the <ruby> element.
<ruby> </ruby>
-
Write the language (usually Chinese or Korean) in which you want to make as base text in which the annotation has to be attached.
<ruby> 印度 </ruby>
-
One <rp> element must enclose the left parenthesis while the other <rp> element must enclose the right parenthesis.
<ruby> 印度 <rp>(</rp> <rp>)</rp> </ruby>
-
Add the annotations using <rt> element between the parenthesis which is also between the </rp> tag and <rp> tag.
<ruby> 印度 <rp>(</rp><rt>India</rt><rp>)</rp> </ruby>
Without <ruby> element, the output will look like- 印度 India
Some web experts use the following shortcut to make ruby annotations, but the output will be same.
<ruby> 印度 <rt>India</rt> </ruby>
Difference between <ruby>, <rb>, <rp> and <rt>
| Tag | Full name | Note |
|---|---|---|
| <ruby> | Ruby container | creates original character and annotation |
| <rb> | Ruby base | wraps the base character. Optional in HTML5. |
| <rp> | Ruby parenthesis | creates fallback character for unsupported browser. |
| <rt> | Ruby text | holds the translated text. |
