Images use the
img tag, and also use attributes to define information about the image. An example of code to display an image is below
<imag src="cat.jpg" alt="My Ginger Cat" width="100" height="100" />
We use the
src attribute to show the location of the image (its source), this must be referenced in the same way we would for a hyperlink (i.e. it needs to full address if it is not within the current website).
alt attribute is used to display alternative text if the image cannot be loaded, or if the user cannot set it for any reason, e.g. using a screen reader
We also specify the
height because the browser does not know the size of the image when laying out the page, we provide this information to help the page display correctly. Although the dimensions refer to pixels, we should only specify numbers for the dimensions, not the unit of measurement.
Be aware that apart from images, videos and objects, specifying sizes of elements should always be done in a style sheet.