HTML-Attributes with Example
Table of Contents
Any HTML elements can have attributes, HTML elements Attributes provide additional information about elements, Any attributes are always specified in the start tag, Attributes usually come in name-value pairs like eg. name=”value”.
src Attribute
The tag is used to embed an image in an HTML web page. The src attribute specifies the path of image.
Example
<img src="image_path">
There are two ways to specify URL in src attribute:-
- Absolute URL
eg. src=”https://www.intechnologies.in/InTechnologiesNew.png“.
2. Relative URL
eg. src=”img/InTechnologiesNew.png”.
width and height Attributes
The <img> tag also has width and height attributes, which specify the width and height of the image.
<img src="image_path" width="200" height="200">
alt Attribute
The alt attribute for the tag specifies an alternate text for an image.
Example
<img src="image_path" alt="this is image alt attribute (alternate text)">
href Attribute
The <a> anchor tag defines a hyperlink. The href attribute specifies the URL of the webpage the link goes to.
Example
<a href="https://intechnologies.in">View</a>
style Attribute
The style attribute is used to add styles to an element, such as color, font, font face, bold, italic and size etc…
Example
<p style="font-family: Arial; color: red; font-size: 14px;">This is a red paragraph.</p>
0 Comments