Colors in CSS

In CSS colors can be implemented by using predefined color names, or RGB, HEX values etc. Some of the examples of using Colors in CSS are as follows :

background Colors :

We can set background color by background-color property. Syntax :
  background-color: color_name;
Example :
<!DOCTYPE>
<html>
   <body>
      <p style="background-color: yellow;">Hello world This is The first Paragraph</p>
      <p style="background-color: orange;">Hello world This is The Second Paragraph</p>
   </body>
</html>
Output :

Hello world This is The first Paragraph
Hello world This is The Second Paragraph


Text Color :

We can set Text color by color property. Syntax :
  color: color_name;
Example :
<!DOCTYPE>
<html>
  <body>
    <p style="color: blue;">Hello world This is The first Paragraph</p>
    <p style="color: gray;">Hello world This is The Second Paragraph</p>
  </body>
</html>
Output :

Hello world This is The first Paragraph
Hello world This is The Second Paragraph


Border color :

We can set border color by color property. Example :
<!DOCTYPE>
<html>
   <body>
     <p style="border:2px solid red;">Hello world This is The first Paragraph</p>
     <p style="border:2px solid blue;">Hello world This is The Second Paragraph</p>
   </body>
</html>
Output :

Hello world This is The first Paragraph

Hello world This is The Second Paragraph


Next Topic :