HTML Styles
Themelites HomeContactAbout
HTML CSS Bootstrap Blogger Template JavaScript PHP

HTML Styles


The style attribute of HTML tags is used to add styles to an element.

We can add text color, font size, font family, and much more.

Syntax of the style attribute is:

<tagname style="property:value;">

where the property is any CSS property and value is the value of the property.

Let's learn with some examples.

Background Color

The CSS background-color property defines the background color for an HTML element.

<body style="background-color: aliceblue;">
<h1>Background color of body is now aliceblue.</h1>

Font Size

The CSS font-size property defines the font size for an HTML element:

<h1 style="font-size: 17px;">Font size of heading is now 17px.</h1>

Text Color

The CSS color property defines the text color for an HTML element:

<h1 style="color: red;">Text color of heading is now red.</h1>

Various other CSS properties are also available using which we can design our webpage.

We can use CSS in three ways. 

  1. Inline
  2. Internal
  3. External

We will learn about them at a later stage.

All the above examples use the inline-css method.

Image credits: undraw

Back to top