HTML – Attributes

Attributes provide additional information of any HTML element. They are defined with any start tag. We can multiple attributes within one element.

They come in name-value pair

<element attribute_name=”value”>Content here!</element> 

Some basic attributes which are used with elements:-

1. Title attribute

This attribute helps to define the extra information about any of the content like a tooltip. We can use this attribute with any of the tags.

<p title="This is a paragraph">Content here!</p> 
<h1 title="This is a heading">Content here!</h1> 
<a title="This is anchor">Content here!</a> 

2. Href attribute

This attribute defines the link where the page goes on click of an anchor tag. We can also control the opening of the link in the same tab or new tab using the target attribute.

<a href="https://testlink.com" target="_blank">Click me!</a>

3. Src attribute

This attribute defines the path of the image. It helps in embedding image with the browser.

<img src="https://www.lecturely.com/wp-content/themes/divi-child/asset/img/image-68.png">

4. Width and height attribute

This attribute helps to define the width and height of the image tag. These values are defined in pixels.


<img src="https://www.lecturely.com/wp-content/themes/divi-child/asset/img/image-68.png" width="400" height="100">

5. Style attribute

This attribute helps to add style to an element. That style can be anything color, font, background color, and more. We can add this style attribute to any of the element.

<p style="color: #000;">Content here!</p>  <h1 style="font-size: 10px;">Content here!</h1>