HTML Styles
The HTML style attribute is used to add styles to an element, such as color, font, size, and more.
Now let's look at various attributes of style and what else the tag supports. The tagname includes <p>, <body>, from <h1> to <h6> etc. The property is borrowed from CSS like color, font-size, font-family etc. The value is also borrowed from CSS.
Cascading Style Sheets (CSS) is a style sheet mechanism that has been specifically developed to meet the needs of Web designers and users.
With CSS, you can specify a number of style properties for a given HTML element. Each property has a name and a value, separated by a colon (:). Each property declaration is separated by a semi-colon (;).
Example of Heading tags
<tagname style="property:value"> </tagname>
The property is a CSS property. The value is a CSS value.
Background Color
Set the background color for a page to blue : <body style="background-color:blue">
<h1>This is a Heading </h1>
<p>This is a Paragraph </p>
</body>
Example Result
This is a Heading
This is a Paragraph
Text Color
Set the background color for a page to blue : <body>
<h1 style="text:red">This is a Heading </h1>
<p style="text:blue">This is a Paragraph </p>
</body>
Example Result
This is a Heading
This is a Paragraph
Text Alignment
align the page content at center : <body>
<h1 style="text-align:center">This is a Heading </h1>
<p style="text-align:center">Lorem ipsum dolor sit amet consectetur adipisicing elit. Perspiciatis minima assumenda culpa incidunt cum, quae, id numquam eos ratione dolorum voluptatibus dicta nemo unde corrupti harum nulla. Reprehenderit obcaecati, optio maxime accusantium quaerat veniam!</p>
</body>
Example Result
This is a Heading
Lorem ipsum dolor sit amet consectetur adipisicing elit. Neque qui rerum voluptatum illum, dolorum consequatur, recusandae quae placeat totam maxime eius at optio eos dolore nihil, atque enim adipisci iste ea harum! Voluptates, fugiat!