Html Tutorial

HTML-Attributes

What are Attributes?

HTML elements have some attributes to provide extra information about that element. These attributes are mentioned in the opening tag of element. An attribute has two parts name and its value.

Some of the attributes are given below with explaination.

id attribute

The id attribute is used to give an element unique identity within a page.

Example

<body>
<p id="first">This is the first paragraph</p>
<p id="second">This is the second paragraph</p>
</body>

As you can see in the above example we can uniquely identify two paragraphs by using their id attribute

title attribute

The title attribute is used to give a title to the element.

Example

<body>
<p title="Title of this element">This is a simple paragraph whose title is specified.</p>
</body>

Output:

This is a simple paragraph whose title is specified.

To see the effect of title attribute hover the mouse cursor on the output. You will notice a tooltip having the same text as you mentioned in title attribute.

href attribute

The href attribute is used to store the link for <a> tag.

Example

<body>
<a href="http://www.tutorialheap.com">Go to home</a>
</body>

style attribute

The style attribute is used to specify CSS rules. you will study more about CSS in later chapters.

Example

<body>
<h2 style="font-family:monospace; color:maroon;">Heading using Style attribute</h2>
</body>

Output:

Heading using Style attribute

Advertisment

Share


Advertisement