You are here: Reference > JavaScript > client-side > style handling > properties > rubyPosition

rubyPosition style property

Browser support:
Specifies or returns the position of the Ruby text (rt).

Syntax:

object.rubyPosition;
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: ruby-position

Possible values:

The type of this property is string.
 One of the following values: 
above
Default. The Ruby text (rt) is located above the base content.
inline
The Ruby text (rt) is located inline with the base content.
Default: above.

Example HTML code 1:

This example illustrates the use of the ruby-position property:
<head>
    <style>
        ruby.example {
            background-color: #EAE9E6;
        }
        rt.example {
            font-size: 12px;
            color: red;
        }
    </style>
</head>
<body>
    <ruby class="example" style="ruby-position: inline;">
        Inline.
        <rt class="example">Ruby text.</rt>
    </ruby>

    <br /><br />

    <ruby class="example" style="ruby-position: above;">
        Above.
        <rt class="example">Ruby text.</rt>
    </ruby>
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the rubyPosition property in JavaScript:
<head>
    <script type="text/javascript">
        function ChangeRubyPosition (selectTag) {
            // Returns the index of the selected option
            var whichSelected = selectTag.selectedIndex;

            // Returns the text of the selected option
            var rubyValue = selectTag.options[whichSelected].text;

            var ruby = document.getElementById ("myRuby");

            if ('rubyPosition' in ruby.style) {
                ruby.style.rubyPosition = rubyValue;
            } else {
                alert ("Your browser doesn't support this example!");
            }
        }
    </script>
</head>
<body>
    <ruby id="myRuby">
        Ruby base.
        <rt>Ruby text.</rt>
    </ruby>

    <br /><br />
    Change rubyPosition property:
    <br />
    <select onchange="ChangeRubyPosition (this)" size="2">
        <option selected="selected" />above
        <option />inline
    </select>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content