HTML elements can have attributes. HTML attributes provide additionally functionality to HTML elements by providing additional information about the element in name/value pairings. HTML attributes always are in the start tag (opening tag) of an HTML element. The following HTML code examples demonstrate the use of HTML attributes in images and links in HTML pages.
In the following HTML code example, the <a> tag indicates a hyperlink, and the ‘href’ attribute provides the URL for the link.
1 2 3 |
<a href="https://www.google.com">Click here to visit Google.</a> |
In the following HTML code example, the <img> tag displays an image on an HTML page, and the source attribute (src) defines the path to the image file.
1 2 3 |
<img src="cool_image_example.jpg"> |