Anne van Kesteren

XHTML Ruby

What is the Ruby Annotation:

"Ruby" are short runs of text alongside the base text, typically used in East Asian documents to indicate pronunciation or to provide a short annotation. This specification defines markup for ruby, in the form of an XHTML module.

However, Ruby can also be used for other things, like abbreviations, which is more interesting for me and probably other people. Consider the following markup:

<ruby>
  <rb>WWW</rb>
  <rt>World Wide Web</rt>
</ruby>

Note that Ruby is not available as HTML, since it is XHTML and that therefore the content-type must be application/xhtml+xml (or a similar content-type). The namespace is the same as for XHTML 1.x documents, namely: http://www.w3.org/1999/xhtml. The better part of Ruby is the "designed for backwards compatibility" RP element (ruby parenthesis). Take a look at the following Ruby construct using that element. It is "exactly" equivalent in semantics with the example above but it differs slightly in display for non ruby supporting browsers, like current versions of Mozilla:

<ruby>
  <rb>WWW</rb>
  <rp>(</rp><rt>World Wide Web</rt><rp>)</rp>
</ruby>

Note here that the default style for the RP element is display:none when Ruby is supported by the browser, older browsers will display: "WWW (World Wide Web)". Looks great to me! Jerome Bos mentioned this to me and I tend to agree with him that Ruby defines much better the relationship between the abbreviation and the abbreviation written full-out. (Styling it is also much easier using a selector like rb:hover+rt or rb:hover~rt in case of the second example. With a bit of positining you could create your own fancy tooltips.)

If you really need Ruby support there is a hacky way of getting support for it in Mozilla. If you are developer with too much free time feel free to implement (real) support for it in Mozilla. I'm not sure if there is a bug for the CSS3 Ruby Module (CR) (couldn't find one) but don't botter filling one.

Comments

  1. Note that Ruby is not available as HTML, since it is XHTML and that therefore the content-type must be application/xhtml+xml (or a similar content-type).

    It's pretty odd, but it's working almost correctly with Internet Explorer (atleast I think so), but as we all know IE cannot serve a document as application/xhtml+xml.

    Posted by Jerome at