files/en-us/web/css/reference/properties/ruby-position/index.md
The ruby-position CSS property defines the position of a ruby element relative to its base element. It can be positioned over the element (over), under it (under), or between the characters on their right side (inter-character).
{{InteractiveExample("CSS Demo: ruby-position")}}
ruby-position: over;
ruby-position: under;
<section id="default-example">
<ruby id="example-element"> 明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp> </ruby>
</section>
#example-element {
font-size: 2em;
}
/* Keyword values */
ruby-position: over;
ruby-position: under;
ruby-position: alternate;
ruby-position: alternate over;
ruby-position: alternate under;
ruby-position: inter-character;
/* Global values */
ruby-position: inherit;
ruby-position: initial;
ruby-position: revert;
ruby-position: revert-layer;
ruby-position: unset;
over
under
alternate
inter-character
over in vertical writing modes. Otherwise, it indicates that the ruby has to be placed between the different characters, appearing on the right of the base in horizontal text and forcing the children of the ruby annotation container to have a vertical-rl writing mode.{{cssinfo}}
{{csssyntax}}
<ruby>
<rb>超電磁砲</rb>
<rp>(</rp><rt>レールガン</rt><rp>)</rp>
</ruby>
ruby {
ruby-position: over;
}
{{EmbedLiveSample("Ruby_positioned_over_the_text", 100, 40)}}
<ruby>
<rb>超電磁砲</rb>
<rp>(</rp><rt>レールガン</rt><rp>)</rp>
</ruby>
ruby {
ruby-position: under;
}
{{EmbedLiveSample("Ruby_positioned_under_the_text", 100, 40)}}
<ruby>
<rb>A</rb><rb>B</rb><rb>C</rb>
<rtc>Above</rtc>
<rtc>Below</rtc>
</ruby>
ruby {
ruby-position: alternate; /* this is also the initial value */
}
{{EmbedLiveSample("Ruby_alternate", 100, 40)}}
{{Specifications}}
{{Compat}}