<mark>はテキストをハイライトするHTMLタグです。mark要素の使い方をサンプルを交えてご紹介します。
HTML要素のタグ名、属性名および属性値は、大文字と小文字のどちらでもよい。mark 要素の終了タグは省略できない。
<mark>
<!-- phrasing content -->
</mark>
<MARK>
<!-- phrasing content -->
</MARK>
mark 要素の開始タグと終了タグの間にフレージング・コンテンツを含めることができる。
There is <mark>no place</mark> like home.
There is no place like home.
以下に示す属性を mark 要素に指定できる。
There is <mark class="bg-primary">no place</mark> like home.
There is <mark style="background-color: violet">no place</mark> like home.
There is no place like home.
There is <mark title="重要">no place</mark> like home.
There is no place like home.
JavaScriptからは HTMLElement インタフェースを通じて mark 要素へアクセスできる。
| プロパティ | 型 | 説明 |
|---|---|---|
| accessKey | string | accessKey属性 |
| accessKeyLabel | string | 要素に割り当てられたアクセスキー(読取り専用) |
| contentEditable | string | contenteditable属性 |
| isContentEditable | boolean | この要素が編集できるかどうか(読取り専用) |
| dataset | DOMStringMap | カスタムデータ属性 |
| dir | string | dir属性 |
| draggable | boolean | draggable属性 |
| innerText | string | ノードに描画されるテキスト |
| lang | string | lang属性 |
| style | string | style属性 |
| tabIndex | number | tabIndex属性 |
| title | string | title属性 |
<a><em><strong><small><s><cite><q><dfn><abbr><ruby><rt><data><time><code><var><samp><kbd><sub><sup><i><b><u><bdo><span><br><wbr>Web Hypertext Application Technology Working Group 2023. Text-level semantics. HTML Living Standard