HTML Attribute

HTML attribute describes the addition features or properties of html element. The html attribute is written in opening tag. Basically it is information or specification about html element. It base on pair of name and value. Name and value both are case sensitive and value is written within quotations. Multiple attributes can be added against a single element, but space should be given between two attributes.

HTML Attribute Syntax

<p attribute_name="value">content</p>

Now we will discuss some of the common attributes as we will proceed further it will become more clearer.

Id Attribute

This attribute is use to give a unique identity to element. By giving id to element it become easier to select or identify the element.

Note: The id of element should be unique, No two elements should have same id.

Example

<!DOCTYPE html>
<html>

<head>
<title>Example</title>
<style>
#para{
      width:70%;
      text-align: center;
      height: 105px;
      background-color: #28a745;
	  }
</style>
</head>

<body>
<p id="para">Welcome to tutorials art</p>
</body>

</html>
HTML Attribute

Title Attribute

This attribute is used to give a title to element, such that, whenever cursor is placed on that element than that title will be viewed to user. So we can say that it is advisory text about an element.

Example

   <h1 title="heading">Title attribute</h1> 
  
   <p title="paragraph"> 
     This is a paragraph click on the text to know its title 
   </p> 

Note: Try this code and place the cursor on text to see how the title tag is actually working.

Style Attribute

The style attribute is used to give the styles to element such that color, width ,font, size and many more.

Example

<p style="color: blue;">This is a blue paragraph.</p>

Comments are closed.