HTML Style Attribute

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

Syntax

style=”property:value;”

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:

Syntax

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

Text Color

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

Syntax

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

HTML Fonts

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

Syntax

<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.

Syntax

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

HTML Text Alignment

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

Syntax

<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
email
1,147 Views