hr 要素
4.5.2 hr 要素
- カテゴリー
- フロー・コンテンツ
- この要素を使うことができるコンテキスト:
- フロー・コンテンツが期待される場所
- コンテンツモデル:
- 空
- コンテンツ属性:
- グローバル属性
- DOMインタフェース:
-
interface HTMLHRElement : HTMLElement {};
hr 要素は、段落レベルのテーマの変わり目を表します。例えば、ストーリーの中でのシーンの変わり目や、リファレンス本のセクションの中での他のトピックへの変わり目です。
次は、プロジェクトの手引きという架空の話ですが、ここには 2 つのセクションがあります。これらのセクションの中で hr 要素を使って、トピックを分離しています。
<section> <h1>Communication</h1> <p>There are various methods of communication. This section covers a few of the important ones used by the project.</p> <hr> <p>Communication stones seem to come in pairs and have mysterious properties:</p> <ul> <li>They can transfer thoughts in two directions once activated if used alone.</li> <li>If used with another device, they can transfer one's consciousness to another body.</li> <li>If both stones are used with another device, the consciousnesses switch bodies.</li> </ul> <hr> <p>Radios use the electromagnetic spectrum in the meter range and longer.</p> <hr> <p>Signal flares use the electromagnetic spectrum in the nanometer range.</p> </section> <section> <h1>Food</h1> <p>All food at the project is rationed:</p> <dl> <dt>Potatoes</dt> <dd>Two per day</dd> <dt>Soup</dt> <dd>One bowl per day</dd> </dl> <hr> <p>Cooking is done by the chefs on a set rotation.</p> </section>
これらのセクションの間に hr 要素を入れる必要はありません。なぜなら、section 要素と h1 要素そのものが、テーマの変わり目という意味を含んでいるからです。
次の例は、Peter F. Hamilton 著の Pandora's Star から抜粋ですが、2 つの段落があります。はじめの段落の後にシーンの変わり目があり、2 つ目の段落がそれに続きます。このシーンの変わり目は、書籍では 2 つ目と 3 つ目の段落の間に 1 つだけのセンタリングされた星を入れ間隔を空けることで表されていますが、ここでは、hr 要素を使って表されています。
<p>Dudley was ninety-two, in his second life, and fast approaching
time for another rejuvenation. Despite his body having the physical
age of a standard fifty-year-old, the prospect of a long degrading
campaign within academia was one he regarded with dread. For a
supposedly advanced civilization, the Intersolar Commonwearth could be
appallingly backward at times, not to mention cruel.</p>
<p><i>Maybe it won't be that bad</i>, he told himself. The lie was
comforting enough to get him through the rest of the night's
shift.</p>
<hr>
<p>The Carlton AllLander drove Dudley home just after dawn. Like the
astronomer, the vehicle was old and worn, but perfectly capable of
doing its job. It had a cheap diesel engine, common enough on a
semi-frontier world like Gralmond, although its drive array was a
thoroughly modern photoneural processor. With its high suspension and
deep-tread tyres it could plough along the dirt track to the
observatory in all weather and seasons, including the metre-deep snow
of Gralmond's winters.</p>
hr 要素は、ドキュメントのアウトラインに影響を及ぼすことはありません。
※ 原文:http://www.w3.org/TR/2011/WD-html5-20110525/grouping-content.html#the-hr-element