<Q> は他の文献からの引用を表わすHTMLタグです。この記事では使い方をサンプルを交えてご紹介します。
開始タグと終了タグに囲まれた文字列が引用 (quotation) であることを表します。Q 要素タイプはインライン要素(前後に改行が入らない)です。引用文をブロック要素(前後に改行が入る)として扱うには、<blockquote> を使用します。
<q>
<!-- phrasing content -->
</q>
開始タグと終了タグは省略できません。開始タグと終了タグの間にはインライン要素が任意回数表れます。
q 要素の開始タグと終了タグの間にフレージング・コンテンツを含めることができる。
q要素には次の属性を指定することができる。
<q cite="https://html.spec.whatwg.org/">
The q element represents some phrasing content quoted from another source.
</q>
q要素で使われる引用符は、CSSの quotes プロパティで指定することができる。
<p style="quotes: '\201C' '\201D' '\2018' '\2019'">
<q>quotes <q>quotes in quotes</q> quotes</q>
</p>
quotes
quotes in quotes
quotes
<p>令和の元号は万葉集の<q>初春令月気淑風和</q>が出典とされています。</p>
令和の元号は万葉集の初春令月気淑風和
が出典とされています。
言語によって引用符に使われる記号は異なる。q要素を使うと、言語に応じて適切な引用符で表示される。
<p lang="en">
<q cite="https://html.spec.whatwg.org/">
The q element represents some phrasing content quoted from another source.
</q>
</p>
The q element represents some phrasing content quoted from another source.
JavaScriptからはHTMLQuoteElementインタフェースを通じてq要素にアクセスできる。
| プロパティ | 型 | 説明 |
|---|---|---|
| className | DOMString | q要素のclass属性 |
| clientHeight | Number | q要素の内部の高さ(読取専用) |
| clientWidth | Number | q要素の内部の幅(読取専用) |
| cite | DOMString | q要素のcite属性 |
| dataset | DOMStringMap | q要素のカスタムデータ属性 |
| dir | DOMString | q要素のdir属性 |
| id | DOMString | q要素のid属性 |
| innerHTML | DOMString | q要素内のマークアップ |
| innerText | DOMString | ノードに描画されるテキスト |
| lang | DOMString | q要素のlang属性 |
| style | CSSStyleDeclaration | q要素のstyle属性 |
| title | DOMString | q要素のtitle属性 |
<a><em><strong><small><s><cite><dfn><abbr><ruby><rt><data><time><code><var><samp><kbd><sub><sup><i><b><u><mark><bdo><span><br><wbr>Web Hypertext Application Technology Working Group (2022) "Text-level semantics" HTML Living Standard