Styles in HTML

More options for you.


General KnowledgeEnglish GrammarMathScienceIQ-TestQuiz-Test

We are now ready to learn how to style HTML element with the style attribute.
Background color is white and text color is black is the default style in all HTML elements.
We could change this default style of our HTML element with style attribute.
The HTML style attribute is like this:
style="property:value"

Example of style attribute:


Now, we are going to change the default text-color of our HTML document and have a look how the browsers display it as below.

HTML Editor

<html>
<body>
<h1 style="color:green"> The heading is green. </h1>
<p style="color:blue"> The paragraph is blue. </p>
</body>
</html>

Web Browser

The heading is green.

The paragraph is blue.

Text-alignment in HTML document.

Text-align is left is the default style in all HTML element.
Now, we are going to change the default text-alignment of our HTML document and have a look how the browsers display it as below.

HTML Editor

<html>
<body>
<h1 style="text-align:center"> The heading is center. </h1>
<p style="text-align:right"> The paragraph is right. </p>
</body>
</html>

Web Browser

The heading is center.

The paragraph is right.



More options for you.


General KnowledgeEnglish GrammarMathScienceIQ-TestQuiz-Test