HTML <figcaption> 標簽
- 上一頁 <fieldset>
- 下一頁 <figure>
定義和用法
<figcaption>
標簽為 <figure>
元素定義標題。
<figcaption>
元素可以放置在 <figure>
元素的第一個或最后一個子元素的位置。
另請參閱:
HTML DOM 參考手冊:Figcaption 對象
實例
例子 1
使用 <figure> 元素標記文檔中的照片,使用 <figcaption> 元素定義照片的標題:
<figure> <img src="tulip.jpg" alt="郁金香" style="width:300px"> <figcaption>圖 1 - 郁金香,百合科,多年生草本植物。</figcaption> </figure>
例子 2
使用 CSS 設置 <figure> 和 <figcaption> 的樣式:
<html> <head> <style> figure { border: 1px #cccccc solid; padding: 4px; margin: auto; } figcaption { background-color: black; color: white; font-style: italic; padding: 2px; text-align: center; } </style> </head> <body> <figure> <img src="tulip.jpg" alt="郁金香" style="width:300px"> <figcaption>圖 1 - 郁金香,百合科,多年生草本植物。</figcaption> </figure> </body> </html>
全局屬性
<figcaption>
標簽還支持 HTML 中的全局屬性。
事件屬性
<figcaption>
標簽還支持 HTML 中的事件屬性。
默認的 CSS 設置
大多數瀏覽器將使用以下默認值顯示 <figcaption>
元素:
figcaption { display: block; }
瀏覽器支持
表中的數字注明了首個完全支持該元素的瀏覽器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
8.0 | 9.0 | 4.0 | 5.1 | 11.0 |
- 上一頁 <fieldset>
- 下一頁 <figure>