MOCKSTACKS
EN
Questions And Answers

More Tutorials









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!


Conclusion

In this page (written and validated by ) you learned about HTML Styles . What's Next? If you are interested in completing HTML tutorial, your next topic will be learning about: HTML Text Formating.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.