An Attribute provides additional properties about the HTML element. An attribute tells the behaviour of the HTML element. Attributes are always specified with a starting tag and Attribute consists of a value/name pairs like style="color : red".  

The attributes which are defined globally can be used on any element but other attributes are defined for particular elements.


title Attribute


The title attribute is used to interpret some additional information about the element. title attribute will display the text when we move the cursor over any text.


Example:

<!DOCTYPE html>

<html>

<body>

  <h1 title="Header">Welcome to HTML5 Tutorial<h1>

  <p title="About">In this tutorial we are going to learn the concept of HTML attributes.</p>

  <p>This is an example of Attributes</p> 

</body>

</html>


OUTPUT:

style Attribute


The style attribute is used to applying CSS property on an HTML element such as font, color, size, etc.


Example


<!DOCTYPE html>

<html>

<body>

  <h3>style Attribute example</h3>

  <p style="color : blue;">This is the example for style attribute</p>

</body>

</html>


OUTPUT:

href Attribute


<a> element is the main element of href attribute. The href attribute is used to specifies the URL of a page.


Example

<!DOCTYPE html>

<html>

<body>

  <h2>href Attribute Example</h2>

  <a href="https://www.svrrtech.com">SVRR TECH</a>

</body>

</html>


OUTPUT:

src Attribute


<img> element is the main element of src attribute. The <img> element is used to insert image in a page. The src attribute is used to define the path for the image to display.


Example:

<!DOCTYPE html>

<html>

<body>

  <h2>src Attribute Example</h2>

  <h3>We can specify the width and height of the image</h3>

  <img src="svrr_tech.jpg" width="200" height="200">

</body>

</html>


OUTPUT:


We can also specify height and width in <img> element.


Post a Comment

Previous Post Next Post