セレクター {プロパティ: 値; }
プロパティ | 意味 | 値 | 指定例 |
---|---|---|---|
font-family | フォント | "family-name", generic-family | "MS ゴシック" |
font-size | 文字サイズ | size | 12pt |
font-style | 斜体 | style | normal, italic, oblique |
font-weight | 太字 | weight | normal, bold |
color | 文字色 | color | blue |
background-color | 文字の背景色 | color | blue |
border | 罫線 | width style color | 1px solid blue |
<span style="プロパティ: 値;"> 文字列 </span>
- <!-- hn11.html -->
- <html>
- <head>
- <title>わたしのホーム・ページ</title>
- <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
- </head>
- <body>
- <h1><span style="color: blue; background-color: yellow">わたしのホーム・ページ </span></h1>
- <h2><span style="color: green">ページの内容</span></h2>
- <h3>家族</h3>
- <h4>ペット</h4>
- <h5>犬</h5>
- <h6><span style="color: red; font-size: 20pt">ホイップ</span></h6>
- <span style="color: red; font-size: 16pt">女の子</span>で、 誕生日は<span style="color: blue; font-size: 16pt">12月14日</span>です。
- </body>
- </html>
□ 実行結果
<タグ style="プロパティ: 値;" ... >
- <!-- hn21.html -->
- <html>
- <head>
- <title>わたしのホーム・ページ</title>
- <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
- </head>
- <body>
- <h1 style="color: blue; background-color: yellow">わたしのホーム・ページ</h1>
- <h2 style="color: green">ページの内容</h2>
- <h3>家族</h3>
- <h4>ペット</h4>
- <h5>犬</h5>
- <h6 style="color: red; font-size: 20pt">ホイップ</h6>
- <span style="color: red; font-size: 16pt">女の子</span>で、誕生日は<span style="color: blue; font-size: 16pt">12月14日</span>です。
- </body>
- </html>
□ 実行結果
<div style="プロパティ: 値;"> 文字列 </div>
- <!-- hn31.html -->
- <html>
- <head>
- <title>わたしのホーム・ページ</title>
- <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
- </head>
- <body>
- <div style="color: aqua">
- <h1 style="color: blue; background-color: yellow">わたしのホーム・ページ</h1>
- <h2 style="color: green">ページの内容</h2>
- <h3>家族</h3>
- <h4>ペット</h4>
- <h5>犬</h5>
- <h6 style="color: red; font-size: 20pt">ホイップ</h6>
- </div>
- <div style="color: white; background-color: black">
- <span style="color: red; font-size: 16pt">女の子</span>で、誕生日は<span style="color: blue; font-size: 16pt">12月14日</span>です。
- </div>
- </body>
- </html>
□ 実行結果
<style type="text/css"> スタイルの指定 </style>
- <!-- hn41.html -->
- <html>
- <head>
- <title>わたしのホーム・ページ</title>
- <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
- <style type="text/css">
- h1 { color: blue; background-color: yellow; }
- h2 { color: green; }
- h6 { color: red; font-size: 20pt; }
- div#heading { color: aqua; }
- span.birthday { color: blue; font-size: 16pt; }
- #sex { color: red; font-size: 16pt; }
- .string {color: white; background-color: black; }
- </style>
- </head>
- <body>
- <div id="heading">
- <h1>わたしのホーム・ページ</h1>
- <h2>ページの内容</h2>
- <h3>家族</h3>
- <h4>ペット</h4>
- <h5>犬</h5>
- <h6>ホイップ</h6>
- </div>
- <div class="string">
- <span id="sex">女の子</span>で、誕生日は<span class="birthday">12月14日</span>です。
- </div>
- </body>
- </html>
□ 実行結果
<link rel="stylesheet" href="uri" type="text/css"/>
□hn51.html
- /* css51.css */
- h1 { color: blue; background-color: yellow; }
- h2 { color: green; }
- h6 { color: red; font-size: 20pt; }
- div#heading { color: aqua; }
- span.birthday { color: blue; font-size: 16pt; }
- #sex { color: red; font-size: 16pt; }
- .string {color: white; background-color: black; }
- <!-- hn51.html -->
- <html>
- <head>
- <title>わたしのホーム・ページ</title>
- <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
- <link rel="stylesheet" href="css51.css" type="text/css"/>
- </head>
- <body>
- <div id="heading">
- <h1>わたしのホーム・ページ</h1>
- <h2>ページの内容</h2>
- <h3>家族</h3>
- <h4>ペット</h4>
- <h5>犬</h5>
- <h6>ホイップ</h6>
- </div>
- <div class="string">
- <span id="sex">女の子</span>で、誕生日は<span class="birthday">12月14日</span>です。
- </div>
- </body>
- </html>
□ 実行結果