HTML <figure> 標籤
示例
使用 <figure> 元素來標記文件中的圖片,使用 <figcaption> 元素來定義圖片的標題
<figure>
<img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
<figcaption>圖1 - 特魯利,普利亞,義大利。</figcaption>
</figure>
自己動手試一試 »
更多“自己嘗試”的例子見下文。
定義和用法
<figure>
標籤指定自包含內容,如插圖、圖表、照片、程式碼列表等。
雖然 <figure>
元素的內容與主體流程相關,但其位置獨立於主體流程,如果刪除它,不應影響文件的流程。
提示:<figcaption> 元素用於為 <figure>
元素新增標題。
瀏覽器支援
表格中的數字表示完全支援該元素的首個瀏覽器版本。
元素 | |||||
---|---|---|---|---|---|
<figure> | 8.0 | 9.0 | 4.0 | 5.1 | 11.0 |
全域性屬性
<figure>
標籤也支援 HTML 全域性屬性。
事件屬性
<figure>
標籤也支援 HTML 事件屬性。
更多示例
示例
使用 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="pic_trulli.jpg" alt="Trulli" style="width:100%">
<figcaption>圖1 - 特魯利,普利亞,義大利</figcaption>
</figure>
</body>
</html>
自己動手試一試 »
相關頁面
HTML DOM 參考:Figure 物件
預設 CSS 設定
大多數瀏覽器會以以下預設值顯示 <figure>
元素
示例
figure {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-right: 40px;
}
自己動手試一試 »