color属性

CSS入門

 
■概要
 
color属性は、単語通り「色」、正確に文字の色を意味します。
 

  • red, blueなど既に定義されている色
  • #000, #FFFFFFなど16進数の色コード
  • rgb(255, 255, 255)などRGB色
  • rgba(200, 100, 150, 0.5)など透明度が摘要されたRGBA色
  •  
    color属性は上記のような値を使用でき、デフォルトはinferitで親要素の色を設定します。
     
     
    ■使用方法

    #text1 { color: blue; }
    #text2 { color: #000; }
    #text3 { color: rgb(0, 0, 255); }
    #text4 { color: rgba(100, 100, 100, 0.5); }

     
    ■例

    <html>
    <body>
     <div style=”color: blue”>blue text</div>
     <div style=”color: #0A0″>green text</div>
     <div style=”color: rgb(255, 0, 0)”>red text</div>
     <div style=”color: rgba(0, 255, 255, 0.5)”>aqua text</div>
    </body>
    </html>

    出力結果

    blue text
    green text
    red text
    aqua text

     
     
     
     

    当サイトは広告を含めています。広告のクリックによる収益は全て当サイトの管理、維持、コンテンツ製作に使われます。

     

    Team ladybird
    タイトルとURLをコピーしました