HTML colors

 

HTML Colors:

Whenever we are building any website or webpage colors are important because if you use colors then website looks awesome.

The <body> tag has following attributes which can be used to set different colors:

Bgcolor  -> to set a color for the background of the page.

Text -> to set a color for the body text

Link -> To set a color for Linked Text

Alink> To set a color to active link or selected link.

Bgcolor:

This is is used to set background color for websie

Example:

<body bgcolor=”yellow”>

<p> This is luckyItHub website</p>

 

Output:

 

 

Text:

This is
used to set color of the text.

Example:

<body
text=“#0000FF”>

<p>
This is luckyItHub website
</p>

 

 

OUTPUT:

 

 

Boarder color:

We can also
set boarder colors for the Text

Example:

<h1
style=“border:
2px solid red;”
>This is LuckyItHub
website
</h1>

<h1
style=“border:
2px solid green;”
>This is LuckyItHub
website
</h1>

<h1
style=“border:
2px solid violet;”
>This is LuckyItHub
website
</h1>

 

 

Output:

 

 

RGB Values:

RGB values
represent colors using the intensities of red, green, and blue.

Example:

<p
style=“color:
rgb(255, 0, 0);”
>This text is red</p>

<p
style=“color:
rgb(0, 0, 255);”
>This text is blue</p>

<p
style=“color:
rgb(0, 255, 0 );”
>This text is green</p>

 

 

Output:

 

 

RGBA Values (with transparency):

RGBA values
are similar to RGB, but with an additional alpha channel for transparency.

Example:

<p
style=“color:
rgb(255, 0, 0,0.5);”
>This text is
semi-transparent red
</p>

<p
style=“color:
rgb(0, 0, 255,0.7);”
>This text is
semi-transparent blue
</p>

<p
style=“color:
rgb(0, 255, 0 ,0.3);”
>This text is
semi-transparent green
</p>

 

 

Output:

 

 

HSL Values:

HSL values
represent colors using hue, saturation, and lightness.

Example:

<p
style=“color:
hsl(0, 100%, 50%);”
>This text is
 red
</p>

<p
style=“color:
hsl(240, 100%, 50%);”
>This text is
 blue
</p>

<p
style=“color:
hsl(120, 100%, 50% );”
>This text is
 green
</p>

 

 

Output:

 

 

 

Join Our Newsletter