HTML Attribute

HTML attribute is the properties of tag to display the content in efficient manner. In other words, we can say attribute is the constraint of tag. For example we use align attribute with <p> tag to display the paragraph in left or center or right position.

All attribute has two parts: 1st is its name and 2nd is its value.

example <p align="center">This is paragraph tag</p>

Note: Attribute define characteristics of tag.

Core Attributes

There are four core attributes that can be used by the majority of HTML elements (although not all) are:

  1. Id
  2. Class
  3. Title
  4. Style

The id Attribute

The id attribute is used to identify the same elements uniquely means in a web page we can use many times <p> tag so for uniquely identify the each <p> tag we use id attribute.

It is very useful when we set the different CSS properties for each paragraph <p> tag in same page or sometimes for JavaScript also. Example:
<p id="para1" align="left"> This is first paragraph.</p>

<p id="para2" align="left">This is second paragraph

Note: id attribute value should be unique.

The Class Attribute

Generally the class attribute is used to set the CSS properties for all tag which have same class name. To set the properties of CSS for two or more than two we should use class attribute with same name.

Note: A class attribute may contain one or more than one name separated by space.

<p class="cls1 cls2 cls3">This is first paragraph

<p class=”cls1 cls3”>This is second paragraph

The title attribute

The title attribute is used to give the title of that tag.

The behavior of this attribute will depend upon the element that carries it, although it is often displayed as a tooltip when cursor comes over the element like image or links or while the element is loading.

<p align="center" title="introduction paragraph!"> This is introduction paragraph. </p>

The style attribute

This attribute is used to set the CSS properties within that tag.

It is called inline style to set the CSS properties.

<p style="color:red; size=20px; text-align:center;">This is paragraph using CSS properties. </p>

At this point of time, we are not learning CSS, so just let's proceed without bothering much about CSS. Here, we need to understand what are HTML attributes and how they can be used while formatting content.


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved