HTML Attribute
HTML attributes are special words which provide additional information about the elements or attributes are the modifier of the HTML element.The Attribute should always be applied with its name and value pair.
Syntax
<element attribute_name="value">content</element>
Example
<!DOCTYPE html>
<html>
<head>
</head><body>
<h4> This is Style attribute</h4>
<p style="height: 50px; color: blue">It will
add style property in element</p>
<p style="color: red">It will change the color of content</p>
</body>
</html>
This is Style attribute
It will add style property in element
It will change the color of content
Explanation of above example:
<p style="height: 50px; color: blue">It will add style property in element</p>
In the above statement, we have used paragraph tags in which we have applied style attribute. This attribute is used for applying CSS property on any HTML element. It provides height to paragraph element of 50px and turns it colour to blue.
<p style="color: red">It will change the color of content</p>
In the above statement we have again used style attribute in paragraph tag, which turns its colour red.
There are some commonly used attributes are given below, and the complete list and explanation of all attributes are given in HTML attributes List.
The title attribute in HTML
Description: The title attribute is used as text tooltip in most of the browsers. It display its text when user move the cursor over a link or any text. You can use it with any text or link to show the description about that link or text. In our example, we are taking this with paragraph tag and heading tag.
<!DOCTYPE html>output:
<html>
<head>
</head>
<body>
<h4 title="This is heading tag">Example of title attribute</h4>
<p title="This is paragraph tag">Move the cursor over the heading
and paragraph, and you will see a description as a tooltip</p>
</body>
</html>
Example of title attribute
Move the cursor over the heading and paragraph, and you will see a description as a tooltip
The href attribute in HTML
Description: The href attribute is the main attribute of anchor tag. This attribute gives the link address which is specified in that link. The href attribute provides the hyperlink, and if it is blank, then it will remain in same page.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h4>Display of href attribute</h4>
<p>Below is the link of anchor tag, click the link and see the next page</p>
<a href="https://touchtogain.blogspot.com">This is a link</a>
</body>
</html>
Display of href attribute
Below is the link of anchor tag, click the link and see the next page
This is a linkThe src Attribute
The src attribute is one of the important and required attribute of element. It is source for the image which is required to display on browser. This attribute can contain image in same directory or another directory. The image name or source should be correct else browser will not display the image.
<!DOCTYPE html>output:
<html>
<head>
</head>
<body>
<h4>Example of src attribute</h4>
<p>HTML images can be diplayed with the help of image tag and
its attribute src gives the sourc for that image</p>
<img src="../image/html.jpg" height="200" width="300">
</body>
</html>
Example of src attribute
HTML images can be diplayed with the help of image tag and its attribute src gives the sourc for that image
😊 Your image is here 😊