Introduction:

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

Description:

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="https://www.sqltutorialspoint.com">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:


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:

Attribute

Description

alt

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

disabled

Specifies that an input element should be disabled

href

Specifies the URL (web address) for a link

id

Specifies a unique id for an element

src

Specifies the URL (web address) for an image

style

Specifies an inline CSS style for an element

title

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


 

 

 

 

 

 

 

 

 





 

0 comments


Leave a comment

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

you may also like