How do you write styles in HTML?

Hi Friends, In this blog post, I am going to explain the most interesting HTML attribute which is an HTML style attribute.

Within this blog post, we will see How do you write styles in HTML? How do you give multiple style attributes in HTML? What are the 4 attributes of body HTML? What is an example of an attribute in HTML? HTML style attribute list, HTML style tag, HTML style tag in body.

The Html style attribute is used to set the property like text size, color(text-color, background-color), text alignment and etc.

there is a proper syntax for writing the HTML style attribute. See the below example for an HTML style sample and standard syntax.

[code]
<tagname style=”property:value;”>
[/code]

Here the property is a CSS property and the value is like a CSS value.


HTML Style – back-ground-color:

Using this property we define the background color of our page or any other HTML element.

The below example set the color of a page to blue. See the below example for the same.

[code]
<body style=”background-color:blue;”>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
[/code]


HTML Style –  text-color:

This property defines the color of an HTML text element. See the below example for the same.

[code]
<h1 style=”color:grey;”>This is a heading</h1>
<p style=”color:blue;”>This is a paragraph.</p>
[/code]


HTML Style – Fonts:

font-family is used to set the font style for an HTML element. See the below example for the HTML style.

[code]
<h1 style=”font-family:Arial;”>This is a heading</h1>
<p style=”font-family:courier;”>This is a paragraph.</p>
[/code]


HTML Style – text size:

This property is used to get the desired font size for the HTML element. See the below example for the same.

[code]
<h1 style=”font-size:250%;”>This is a heading</h1>
<p style=”font-size:150%;”>This is a paragraph.</p>
[/code]


HTML Style –  text Alignment:

This HMTL property defines the text alignment of an HTML element in the horizontal direction. See the below example for the same Html style.

[code]
<h1 style=”text-align:center;”>Centered Heading</h1>
<p style=”text-align:left;”>Centered paragraph.</p>
[/code]


Conclusion:

We have gone through How do you write styles in HTML? How do you give multiple style attributes in HTML? What are the 4 attributes of body HTML? What is an example of an attribute in HTML?

In case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.

Hope! you would have enjoyed this post about HTML Style.

Please feel free to give your important feedback in the comment section below.

Have a great time! Sayonara!

Anurag

I am a blogger by passion, a software engineer by profession, a singer by consideration and rest of things that I do is for my destination.