HTML - CSS概要


■ページ目次

Top

■スタイル・シートの基本

Top
■文字列の指定
■例題
  1. 見出しタグにスタイルを指定した例です。(hn11.html)
    1. <!-- hn11.html -->
    2. <html>
    3. <head>
    4. <title>わたしのホーム・ページ</title>
    5. <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
    6. </head>
    7. <body>
    8. <h1><span style="color: blue; background-color: yellow">わたしのホーム・ページ </span></h1>
    9. <h2><span style="color: green">ページの内容</span></h2>
    10. <h3>家族</h3>
    11. <h4>ペット</h4>
    12. <h5>犬</h5>
    13. <h6><span style="color: red; font-size: 20pt">ホイップ</span></h6>
    14. <span style="color: red; font-size: 16pt">女の子</span>で、 誕生日は<span style="color: blue; font-size: 16pt">12月14日</span>です。
    15. </body>
    16. </html>

    □ 実行結果

    
    
Top
■要素内の指定
■例題
  1. 見出しタグにスタイルを指定した例です。(hn21.html)
    1. <!-- hn21.html -->
    2. <html>
    3. <head>
    4. <title>わたしのホーム・ページ</title>
    5. <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
    6. </head>
    7. <body>
    8. <h1 style="color: blue; background-color: yellow">わたしのホーム・ページ</h1>
    9. <h2 style="color: green">ページの内容</h2>
    10. <h3>家族</h3>
    11. <h4>ペット</h4>
    12. <h5>犬</h5>
    13. <h6 style="color: red; font-size: 20pt">ホイップ</h6>
    14. <span style="color: red; font-size: 16pt">女の子</span>で、誕生日は<span style="color: blue; font-size: 16pt">12月14日</span>です。
    15. </body>
    16. </html>

    □ 実行結果

    
    
Top
■ブロックの指定
■例題
  1. 見出しタグにスタイルを指定した例です。(hn31.html)
    1. <!-- hn31.html -->
    2. <html>
    3. <head>
    4. <title>わたしのホーム・ページ</title>
    5. <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
    6. </head>
    7. <body>
    8. <div style="color: aqua">
    9. <h1 style="color: blue; background-color: yellow">わたしのホーム・ページ</h1>
    10. <h2 style="color: green">ページの内容</h2>
    11. <h3>家族</h3>
    12. <h4>ペット</h4>
    13. <h5>犬</h5>
    14. <h6 style="color: red; font-size: 20pt">ホイップ</h6>
    15. </div>
    16. <div style="color: white; background-color: black">
    17. <span style="color: red; font-size: 16pt">女の子</span>で、誕生日は<span style="color: blue; font-size: 16pt">12月14日</span>です。
    18. </div>
    19. </body>
    20. </html>

    □ 実行結果

    
    
Top
■ページ全体の指定
■例題
  1. 見出しタグにスタイルを指定した例です。(hn41.html)
    1. <!-- hn41.html -->
    2. <html>
    3. <head>
    4. <title>わたしのホーム・ページ</title>
    5. <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
    6. <style type="text/css">
    7. h1 { color: blue; background-color: yellow; }
    8. h2 { color: green; }
    9. h6 { color: red; font-size: 20pt; }
    10. div#heading { color: aqua; }
    11. span.birthday { color: blue; font-size: 16pt; }
    12. #sex { color: red; font-size: 16pt; }
    13. .string {color: white; background-color: black; }
    14. </style>
    15. </head>
    16. <body>
    17. <div id="heading">
    18. <h1>わたしのホーム・ページ</h1>
    19. <h2>ページの内容</h2>
    20. <h3>家族</h3>
    21. <h4>ペット</h4>
    22. <h5>犬</h5>
    23. <h6>ホイップ</h6>
    24. </div>
    25. <div class="string">
    26. <span id="sex">女の子</span>で、誕生日は<span class="birthday">12月14日</span>です。
    27. </div>
    28. </body>
    29. </html>

    □ 実行結果

    
    
    
Top
■サイト全体の指定
■例題
  1. 見出しタグにスタイルを指定した例です。(hn51.html)

    css51.css
    1. /* css51.css */
    2. h1 { color: blue; background-color: yellow; }
    3. h2 { color: green; }
    4. h6 { color: red; font-size: 20pt; }
    5. div#heading { color: aqua; }
    6. span.birthday { color: blue; font-size: 16pt; }
    7. #sex { color: red; font-size: 16pt; }
    8. .string {color: white; background-color: black; }
    hn51.html
    1. <!-- hn51.html -->
    2. <html>
    3. <head>
    4. <title>わたしのホーム・ページ</title>
    5. <meta http-equiv="Content-type" content="text/html; charset=Shift_JIS"/>
    6. <link rel="stylesheet" href="css51.css" type="text/css"/>
    7. </head>
    8. <body>
    9. <div id="heading">
    10. <h1>わたしのホーム・ページ</h1>
    11. <h2>ページの内容</h2>
    12. <h3>家族</h3>
    13. <h4>ペット</h4>
    14. <h5>犬</h5>
    15. <h6>ホイップ</h6>
    16. </div>
    17. <div class="string">
    18. <span id="sex">女の子</span>で、誕生日は<span class="birthday">12月14日</span>です。
    19. </div>
    20. </body>
    21. </html>

    □ 実行結果

    
    
    
Top

inserted by FC2 system