×

Html & Html5

The World's best Software Development Study Portal

HTML Style Attribute


With style attribute,we can provide style to our HTML element. The HTML style attribute has the following syntax:

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


1. Background color

    You can set the background color for HTML elements:

     Let's understand this by the following example:

<h1 style="background-color:DodgerBlue"> Hello World </h1>

Output:


backo


2. Text Color

    You can set the color of text.
     Let's understand this by the following example:

<h3 style="color:Tomato"> Hello World </h3>

Output:


texto


3. HTML Fonts

    The font-family property defines the font to be used for an HTML element.
     Let's understand this by the following example:


<h1 style="font-family:verdana"> This is a heading </h1>

<h1 style="font-family:courier"> This is a paragraph. </h1>

Output:


fonto


4. HTML Text Size

    The font-size property defines the text size for an HTML element.

     Let's understand this by the following example:


<h1 style="font-size:300%"> This is a heading </h1>

<p style="font-size:160%"> This is a paragraph </p>

Output:


tsize


5. HTML Text Alignment

    The text-align property defines the horizontal text alignment for an HTML element.

     Let's understand this by the following example:


<h1 style="text-align:center"> Centered Heading </h1>

Output: