HTML Style Attribute

Style’ attribute is the key to give the style to the HTML element.



Here, property refers to CSS property, whereas value refers to CSS value.


HTML Background Color

The background color for an HTML element is defined by the back-ground color property. The syntax for using it is as follows:


<body style=”background-color:red;”>

Text Color

The color property is used to define the text color of an element.


<p style=”color=red;”>Welcome to Technology Diving</p>

HTML Fonts

Font-family property is used for defining the font to be used.


<p style=”font-family:arial;”>Welcome to Technology Diving</p>

HTML Text Size

Font-size property is used for the defining the size of the text.


<p style=”font-size:80%;”>Welcome to Technology Diving</p>

HTML Text Alignment

Text-align property is used for defining the text alignment horizontally.


<p style=”text-align:left;”<Technology Diving</p>

A quick glance over styling attributes

  • For background color: background-color
  • For text color: color
  • For text font: font-family
  • For text size: font-size
  • For text alignment: text-align