The itemprop attribute is a label that tells machines what kind of information the element contains (e.g., name, author, price).
Webページの要素に「この部分は○○という情報だよ」と名前を付けるためのマイクロデータ属性です。検索エンジンや音声アシスタントなどの機械がページ内容を正しく理解しやすくなります。
itemscope
+itemtype
で示した「ひとまとまりの情報(アイテム)」の中で、itemprop
は各要素の「項目名(プロパティ)」を指定する。
例:本(アイテム)の「title」「author」「price」など。
HTML
<div itemscope itemtype="https://schema.org/Book">
<span itemprop="name">吾輩は猫である</span>
<span itemprop="author">夏目漱石</span>
<meta itemprop="datePublished" content="1905-01-01">
</div>
itemscope
itemtype
で「Book」というタイプを宣言。
itemprop="name"
などで各要素にラベルを付ける。
meta
要素を使えば表示せずに値だけ提供できる。
itemprop
だけ書いて itemscope
/itemtype
を書かないitemprop
は「この要素は〇〇という属性ですよ」と機械に伝える名札。
itemscope
/itemtype
とセットで使い、検索や音声アシスタントに優しいページを作りましょう。