Attributes provide additional information about HTML elements.
HTML links are defined with the <a> tag. The link address is specified in the href attribute:
<a href="https://www.learncomputer.in">This is a link.</a>You will learn more about links and the <a> tag later in this tutorial.
HTML images are defined with the <img> tag.
The filename of the image source is specified in the src attribute:
<img src="img_girl.png">HTML images also have width and height attributes, which specifies the width and height of the image:
<img src="img_girl.jpg" width="500" height="600">You will learn more about attributes in a later chapter.
You will learn more about images in our HTML Images chapter.
The alt attribute specifies an alternative text to be used, if an image cannot be displayed.
The value of the alt attribute can be read by screen readers. This way, someone "listening" to the webpage, e.g. a vision impaired person, can "hear" the element.
<img src="img_girl.jpg" alt="Girl with a jacket">Setting the style of an HTML element, can be done with the style attribute.
The HTML style attribute has the following syntax:
<tagname style="property:value;">The property is a CSS property. The value is a CSS value.