HTML Styles

HTML is primarily used to defines the structure of the web page While Cascaded style sheets (CSS) are a language that is used for the presentation of HTML Page.

Using CSS in HTML, we can change colors, fonts and other kinds of formatting on a web page. There are many different ways to include CSS in an HTML page. We will see a simple way to apply CSS Rules in the HTML Document.


You can use style attributes to apply CSS in any HTML page.


HTML Background Color

We can set background colors for various HTML Elements.

The background-color property is used to define the background color.

Example of HTML Styles – Background Color
<body style="background-color:lightblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>

HTML Text Color

We can change the color of the text using color properties in any HTML element.

Example of HTML Text color
<h1 style="color:black;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>

HTML Fonts

The font-family property is used to defines the font types for an HTML elements.

Example of HTML Font
<h1 style="font-family:arial;">This is a heading</h1>
<p style="font-family:Times New Roman;">This is a paragraph.</p>

HTML Text Size

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

Example of HTML Text Size
<h1 style="font-size:15px;">This is a heading</h1>
<p style="font-size:20px;">This is a paragraph.</p>

HTML Text Alignment

The text-align property is used to set horizontal text alignment for an HTML element.

Example of HTML Text Alignment
<h1 style="text-align:right;">right heading</h1>
<p style="text-align:center;">This is a paragraph.</p>

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.