<rt> Tag in HTML | Ruby Text
The <rt> tag in HTML is used to define the ruby text that provides additional information, such as pronunciation, to the main text in the <ruby> element. This is commonly used in East Asian languages to display phonetic annotations.
Key Points on <rt> Tag:
- The <rt> tag is used within the <ruby> element to specify the ruby text that provides a pronunciation guide or annotation.
- The <ruby> tag holds the main text, and the <rt> tag contains the supplementary ruby text.
- Ruby annotations are especially useful for languages like Japanese and Chinese, where characters can have multiple readings.
- Browsers that support ruby annotations will display the ruby text above or beside the main text.
- If ruby annotations are not supported by a browser, it is recommended to provide fallback content using the <rp> tag.
Syntax of <rt> Tag:
Syntax Example
<ruby>Main Text<rt>Ruby Text</rt></ruby>
Example of <rt> Tag in HTML:
This example demonstrates how to use the <rt>
tag for ruby text.
Code Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML <rt> Tag Example</title>
</head>
<body>
<h1>HTML <rt> Tag Example</h1>
<p>
<ruby>漢字<rt>Kanji</rt></ruby>
</p>
</body>
</html>
Output
HTML
漢字
The <rt>
tag is essential for providing ruby text (pronunciation or annotation) in the <ruby>
element, improving readability and understanding, especially for complex characters in East Asian languages. It enhances the accessibility of text by offering additional context.