HTML Style Attribute

HTML Style Attribute

HTML Style Attribute

HTML Style attribute is used to give style (like text color, text fonts, background color etc.) to the content of web page.

  • HTML Style attributes are defined by style="property:value;" syntax.

  • In the place of property, we can give properties like color, font-size, width, height etc.

  • In the place of value, we can give values of properties like color(red, greeen, blue), font-size(10px, 20px) etc.

  • It can be used with any HTML element inside Opening tag.


Example:
<p style="color:blue;">The text comes in blue color.</p>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Style Attribute.

  • In Paragraph Tag, we have used color style attribute which is used to give color to the text. For more HTML Text Color

Run the code to see the effect.

Example:
<b style="font-family:courier;">The text comes in courier font.</b>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Style Attribute.

  • In Bold Tag, we have used font-family style attribute which is used to give different fonts to the text. For more HTML Fonts

Run the code to see the effect.

Example:
<h2 style="text-align:center;">The text comes in the center.</h2>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Style Attribute.

  • In Heading Tag, we have used text-align style attribute which is used to align the text on the web page. For more HTML Text Alignment

Run the code to see the effect.

Example:
<p style="font-size:30px;">The text become 30px in size.</p>
Run Code »
Example Explanation:

In the above, we have shown an example of HTML Style Attribute.

  • In Paragraph Tag, we have used font-size style attribute which is used to change the font size of the text. For more HTML Text Size

Run the code to see the effect.




How To Use More Than One Style Attribute

Two or more style attribute can be used in same HTML element and each style should be separated with (;) semi-colon.

Example:
<p style="color:blue; font-family:courier;">The text comes in blue color with courier font.</p>
Run Code »

HTML Style Attribute in Hindi

Best Use:360p or more (480p or 720p)