HTML `<ruby>` Element: Creating Ruby Annotations for Enhanced Readability
Learn how to use the HTML `<ruby>` element to create ruby annotations, particularly useful for East Asian languages. This tutorial shows how to add pronunciation guides (furigana) or character meanings, improving readability and comprehension for users. Master semantic markup for enhanced text presentation.
Using the HTML `<ruby>` Element for Ruby Annotations
Understanding Ruby Annotations
The HTML `<ruby>` element is used to create ruby annotations—a way to add extra explanatory text alongside main text. Ruby annotations are commonly used in East Asian languages (like Japanese) to show pronunciation (furigana) or to provide the meaning of characters. The annotation is displayed visually near the main text, enhancing readability. This is particularly useful when working with characters that might be unfamiliar to readers. The `<ruby>` tag uses the `
Basic Ruby Annotation Structure
A basic ruby annotation uses the `<ruby>` and `
Example: Basic Ruby Annotation
<ruby>
漢 <rt>kan</rt>
</ruby>
In this example, "kan" (the pronunciation) is the annotation for the character "漢".
Browser Support for `<ruby>` and ``
The `<ruby>` and `
Browser | Support |
---|---|
Chrome | Yes |
Edge | Yes |
Firefox | Yes |
Opera | Yes |
Safari | Yes |
Styling Ruby Annotations with CSS
You can customize the appearance of ruby annotations using CSS. The example below provides basic styling options, including altering the font size and color:
Example: Styling Ruby Annotation with CSS
ruby > rt {
font-size: 0.7em;
color: green;
}