Ruby supplies pronunciation notes above or next to text, often for East Asian writing systems. Rt contains the reading; rp can offer punctuation fallback.
What You Need to Know
The number and placement of annotations should match the text they explain. This is specialized language markup, not a decoration trick.
The goal is not to collect as many tags as possible. Pick the element that best describes what the content really is.
Example: See It in Action
This example keeps the idea small. Copy it carefully, then follow the explanation instead of guessing what the browser will do.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<ruby>
漢 <rp>(</rp><rt>kan</rt><rp>)</rp>
字 <rp>(</rp><rt>ji</rt><rp>)</rp>
</ruby>
Let’s Understand the Example
- Ruby groups a word or character with an annotation, often to show pronunciation.
- Rt holds the pronunciation or other annotation for ruby text.
- Rp gives punctuation fallback around ruby annotations in older environments.
Look for the text “漢” in the page. If the visible result surprises you, inspect the rendered elements to see what the browser actually built.
What Should You See?
The page should include “漢”. If it looks different from what you expected, open developer tools and compare the source with the elements the browser created.
Try removing one piece of markup in a scratch copy, refresh the page, and compare the behavior. This is often the fastest way to understand what that piece contributes.
Try It Yourself
- Add a ruby annotation for a word you know, matching each base text part carefully.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Putting an entire unrelated translation inside rt as if it were ordinary body text.
- Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.
Key Takeaways
- Ruby supplies pronunciation notes above or next to text, often for East Asian writing systems.
- Ruby groups a word or character with an annotation, often to show pronunciation.
- The number and placement of annotations should match the text they explain. This is specialized language markup, not a decoration trick.