HTML Styles


Go to main Page

Styles in HTML

The HTML style attribute has following syntax:


<tagname style="property:value;"></tagname>

 

Background-Color Property

This propert is used to change the background color of elements.


<h1 style="background-color:yellow;">We are changing background color of h1 tag</h1>

<p style="background-color:orange;">We are changing background color of paragraph tag</p>

 


Text Color Property

This propert is used to change the text color of elements.


<h1 style="color:red;">We are changing text color of h1 tag</h1>

<p style="color:green;">We are changing text color of paragraph tag</p>

 


Font Size & Font family Property

This propert is used to change the font properties of elements.


<h1 style="font-size:40px;">We are changing font size of h1 tag</h1>

<p style="font-size:30px;">We are changing font size of paragraph tag</p>

<h1 style="font-family:monospace;">We are changing font family of h1 tag</h1>

<p style="font-size:arial;">We are changing font family of paragraph tag</p>

 


Border Property

This propert is used to apply border to elements.


<h1 style="border:2px solid blue;">We are applying border of h1 tag</h1>

<p style="border-top:2px solid red;">We are applying border at the top of paragraph tag</p>

<h1 style="border-bottom:3px solid green;">We are applying bottom border of h1 tag</h1>

<p style="border-left:2px solid purple;">We are applying left border of paragraph tag</p>