In this article we will learn what is attribute in html and how to use attribute in html with example.


An HTML attribute is an associated property of an HTML element and used to extend the capability of an HTML element. All attributes are made up of two parts − a name and a value. Attributes are always specified in the start tag.

Let’s see example

<a href="">This is a link</a>

In above example HTML links are defined with the <a> tag. The link address is specified in the href attribute:

how to use html attribute with example

Image src Attribute

<img src="download.jpg" />

In above code HTML images are defined with the <img> tag.

The filename of the image source is specified in the src attribute:

The width and height Attributes

Images in HTML have a set of size attributes, which specifies the width and height of the image:

<img src="download.jpg" width="300" height="500" />

The image size is specified in pixels: width="300" means 300 pixels wide.

The alt Attribute

The alt attribute specifies an alternative text to be used, when an image cannot be displayed.

<img src="download.jpg" alt="sql tutorials point" />

In above example alt is attribute and sql tutorials point value.

HTML Attributes

Below is generic list of some attributes often used in HTML:




Specifies an alternative text for an image, when the image cannot be displayed


Specifies that an input element should be disabled


Specifies the URL (web address) for a link


Specifies a unique id for an element


Specifies the URL (web address) for an image


Specifies an inline CSS style for an element


Specifies extra information about an element (displayed as a tool tip)












Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

you may also like