Learn Simpli

Free Online Tutorial For Programmers, Contains a Solution For Question in Programming. Quizzes and Practice / Company / Test interview Questions.

Attributes give additional information about the HTML tags. All elements can have attributes, these are always specified with start tag.

Example: name=”value”

href attribute: HTML links are specified using anchor tag <a> and the address links are written in the href tag attribute.

Example:

<a href="https://www.learnsimpli.com">This is a link</a>

Source attribute: images in the HTML are displayed using the tag <img>, the address link of the image is defined in the <img> attribute.

Example:

<img src="http://www.learnsimpli.com/wp-content/uploads/2019/12/HTML.png">

Width and height attribute: height and width of the image are defined in pixels in the example you can see the width is defined 500 pixels wide and height is defined 600 pixels.

Example:

<img src="http://www.learnsimpli.com/wp-content/uploads/2019/12/HTML.png" width="500" height="600">

The alt Attribute:alt the attribute depicts an alternative text to be used. The value of the alt attribute can be read on the web page.

Example:

<img src="horse.jpg" alt="a beautiful Horse">

The style Attribute: style attribute is used to specify the styling of an element, like colour, font, size etc.

Example:

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

The lang Attribute: The language of the document can be declared in the HTML with a lang attribute. declaring a language helps the reader to understand the language of the document.

Example:

<!DOCTYPE html>
<html lang="en-US">
<body>

...

</body>
</html>

The title Attribute: title attribute is added to the <p> element. The value of the title attribute will be displayed as a tooltip.

Example:

<p title="I'm a tooltip">
This is a paragraph.
</p>

HTML Attributes

Attribute Description of the attribute
alt Specifies an alternate 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 tooltip)

Note: In HTML both single quote and double quotes can be used to define attributes

2 thoughts on “HTML ATTRIBUTES

Comments are closed.