figure

figureタグの概要

figureタグは、画像や図表などのコンテンツをグループ化するためのタグです。主に文章の中に画像や図表を挿入する際に使用されます。

基本の書き方(構文)

<figure>
  <img src="image.jpg" alt="Image">
  <figcaption>This is an image</figcaption>
</figure>

主な属性とその説明

figureタグには特定の属性はありませんが、子要素としてimgタグやfigcaptionタグを含めることが一般的です。

使用例

<figure>
  <img src="image1.jpg" alt="Image 1">
  <figcaption>This is the first image</figcaption>
</figure>

<figure>
  <img src="image2.jpg" alt="Image 2">
  <figcaption>This is the second image</figcaption>
</figure>

<figure>
  <img src="image3.jpg" alt="Image 3">
  <figcaption>This is the third image</figcaption>
</figure>

よくある注意点・間違い

figureタグを使用する際には、必ず適切なalt属性を画像に設定し、図表の説明をfigcaptionタグで明記することが重要です。また、余分なdivタグなどを使用せずにfigureタグを適切に活用することがSEOやアクセシビリティの観点から重要です。