---
title: <ruby>
slug: Web/HTML/Element/ruby
tags:
  - Element
  - HTML
  - Ruby
  - Web
  - zh-Hans
  - 汉字
translation_of: Web/HTML/Element/ruby
---
<p>{{HTMLRef}}</p>

<p><strong>HTML <code>&lt;ruby&gt;</code> 元素 </strong>被用来展示东亚文字注音或字符注释。</p>



<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/Web/HTML/Content_categories" title="HTML/Content_categories">内容范畴</a></th>
   <td><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content" title="HTML/Content_categories#Phrasing_content">流式内容</a>, <a href="/en-US/docs/Web/HTML/Content_categories#Phrasing_content" title="HTML/Content_categories#Phrasing_content">短语内容</a>, palpable content.</td>
  </tr>
  <tr>
   <th scope="row">允许内容</th>
   <td><a href="/en-US/docs/Web/HTML/Content_categories#Phrasing_content" title="HTML/Content_categories#Phrasing_content">短语内容</a></td>
  </tr>
  <tr>
   <th scope="row">标签省略</th>
   <td>{{no_tag_omission}}</td>
  </tr>
  <tr>
   <th scope="row">允许的父级元素</th>
   <td>See prose</td>
  </tr>
  <tr>
   <th scope="row">DOM 接口</th>
   <td>{{domxref("HTMLElement")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Attributes" name="Attributes"><strong>属性</strong></h2>

<p>本元素支持 <a href="/en-US/docs/Web/HTML/Global_attributes" title="HTML/Global attributes">全局属性</a>。</p>

<h2 id="Examples" name="Examples"><strong>示例</strong></h2>

<h3 id="示例1_字">示例 1: 字</h3>

<pre class="brush:html">&lt;ruby&gt;
  汉 &lt;rp&gt;(&lt;/rp&gt;&lt;rt&gt;han&lt;/rt&gt;&lt;rp&gt;)&lt;/rp&gt;
  字 &lt;rp&gt;(&lt;/rp&gt;&lt;rt&gt;zi&lt;/rt&gt;&lt;rp&gt;)&lt;/rp&gt;
&lt;/ruby&gt;</pre>

<h3 id="示例2_词">示例 2: 词</h3>

<pre class="brush:html">&lt;ruby&gt;
  明 日 &lt;rp&gt;(&lt;/rp&gt;&lt;rt&gt;ming ri&lt;/rt&gt;&lt;rp&gt;)&lt;/rp&gt;
&lt;/ruby&gt;</pre>

<h2 id="Specifications" name="Specifications">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'text-level-semantics.html#the-ruby-element', '&lt;ruby&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'text-level-semantics.html#the-ruby-element', '&lt;ruby&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性"><strong>浏览器兼容性</strong></h2>

<div id="compat-desktop">{{Compat("html.elements.ruby")}}</div>

<h2 id="See_also" name="See_also">参阅</h2>

<ul>
 <li>{{HTMLElement("rt")}}</li>
 <li>{{HTMLElement("rp")}}</li>
 <li>{{HTMLElement("rb")}}</li>
 <li>{{HTMLElement("rtc")}}</li>
 <li>{{HTMLElement("rbc")}}</li>
 <li>{{CSSxRef("text-transform")}}: full-size-kana</li>
</ul>

<div id="gtx-trans" style="position: absolute; left: 5px; top: 141px;">
<div class="gtx-trans-icon"></div>
</div>