【caption-side】の使い方
「セルの枠線」も外部CSSで指定することで、HTMLソースがすっきりし、SEO対策(内部対策)として検索エンジン最適化に有効です。
SEO初心者でも簡単に検索上位表示ができるように、サンプルをご紹介しますので、アクセスアップにお役立て下さい。
【caption-side】の書式
caption-side: 値;
- テーブルのタイトル位置を指定する場合は、キーワードで指定する。
※実際の表示や見え方は、ブラウザや使用環境に依存します。
また、SEO対策に不要と思われる値やキーワードは、独断で掲載していませんので予めご了承下さい。
【caption-side】のキーワード(値)
| キーワード(値) | 説明 |
|---|---|
| top | タイトルを上側に指定(デフォルト) |
| bottom | タイトルを下側に指定 |
【caption-side】の使用例
「セレクタ名」と「値」は、お好みで指定して下さい。
テーブルのタイトル位置を「top」に指定。
▼ 表示
▼ HTML
<table class="sample-table"> <tr> <caption> class="sample01"</caption> <td>fixed</td> <td>テーブル1行目の内容を読込んでレイアウト設定。</td> <td>auto</td> <td>テーブル全体の内容を読込んでレイアウト設定。</td> </tr> </table>
▼ CSS
td {
border: 1px solid #FF99FF;
background-color: #FFCCFF;
}
.sample-table {
width: 450px;
margin: 10px auto;
padding: 3px;
text-align: left;
border: 1px solid #FF99FF;
border-collapse: collapse;
table-layout: fixed;
}
.sample01 {
caption-side: top;
}
テーブルのタイトル位置を「bottom」に指定。
▼ 表示
▼ HTML
<table class="sample-table"> <tr> <caption> class="sample02"</caption> <td>fixed</td> <td>テーブル1行目の内容を読込んでレイアウト設定。</td> <td>auto</td> <td>テーブル全体の内容を読込んでレイアウト設定。</td> </tr> </table>
▼ CSS
td {
border: 1px solid #FF99FF;
background-color: #FFCCFF;
}
.sample-table {
width: 450px;
margin: 10px auto;
padding: 3px;
text-align: left;
border: 1px solid #FF99FF;
border-collapse: collapse;
table-layout: fixed;
}
.sample02 {
caption-side: bottom;</i>
}