Attributes of HTML Tags

In this tutorial, the attributes of HTML tags are described.

HTML attributes gives additional information about an element or tag. Almost all HTML elements can have attributes. Attributes are always mentioned in the start tag. Attributes normally come in name-value pairs. See the syntax below:

<tag attribute-name="value">
 
Example:

The “style” attribute is used to denote the styling of an HTML element, like color, font, size etc. See the code snippet below:

<p style="color:blue">This is a sample paragraph.</p>
 
See more coding examples below.
 
 

Example 3 [Define web page background color using “bgcolor” tag]:-

<html>
<body bgcolor="lightblue">

<p>
This is a paragraph. This is a paragraph. This is a paragraph.
</p>

<p>
This is another paragraph. This is another paragraph. This is another paragraph.
</p>

</body>
</html>

 

Output:

 

 

Example 4 [Define text font using “font” tag]:-

The following example shows that an HTML tag can have more than one attribute.

<html>
<body bgcolor="lightblue" text="red">

<p>
<font size="3" face="Verdana">
This is a paragraph.
</font>
</p>

<p>
<font size="4" face="Times">
This is another paragraph.
</font>
</p>

</body>
</html>

 

Output: