HTML Attribute

HTML Attribute


Define : 

HTML attribute provide more and additional information about HTML elements.

  •  It is used to define the characteristics of an element.
  •  It is placed inside the opening tag
  •  It is made up of two parts:name and value . Name and value are two attribute.

Output :

 

The href Attribute

This ( anchor tag) tag defines a hyperlink.The href attribute provides a URL or hyperlink of the page this link goes to:

Output :

The src Attribute

The image tag () is used to embeddding the image in an HTML page. The src attribute provides the path to the image to be displayed of the browser or other media.

Output :

There are two ways to identify the URL in the src attribute:

  1. Absolute URL - It is links to an external image and hosted on another website. for example:

          src="https://www.webdesigninghouse.com/image/banner.jpeg"

      2.    Relative URL - It  links to an  image that is hosted within the website.

           -In relative URL does not include the domain name   

           -if the URL begins the without slash that is the relative to the current page.

            for example: src="img_girl.jpg".

          - if the URL begins with a slash that is the relative to the domain.

            for example: src="/images/img_girl.jpg".

             tip: Mostly relative URL are used and they will not break if you change the domain.

The width and height Attributes  

The image tag () also contain the width and height attributes.That is identify the width and height of the image (pixels,pc,rem).

Output :

The alt Attribute

The alt attribute inside used the tag and specifies an alternative text for an image,if the image for some reason cannot displayed ,this can be the slow connection or an error in the src attribute.

Output :

 

 The style Attribute

Style attribute is used to add styles to an element ,such as color,size,font,background color,background image and more.

Output :