The image tag is essential in HTML to add images to web pages. The tag includes attributes, with “src” being the most important, indicating the location of the image file. Other attributes like alt, border, size, and align can adjust the appearance of the image on the page.
When you create a web page using HTML, the image tag is used to place a photo or graphic at a particular spot on the page. There are many ways images can be used in web pages, from adding interest to being used as a navigational aid or to convey information. There are also different image formats that can be used. No matter how or what image is added to the web page, the image tag is always needed.
To add an image, the image tag is included where you want the image to appear on your page. For example, if an image were to be inserted after this paragraph, the image tag, or, would be added to the HTML document after this paragraph. the tag defines all images in HTML. It is referred to as an empty tag, as it contains attributes and has no closing tag. Attributes are options available for a specific HTML tag.
If only they have been added to an HTML document, nothing is shown since the tag’s attributes have not been included. The most important attribute for is “src”, which stands for source. The src attribute indicates where the image file actually is or is the address of the image file. Since the image is being used on a web page, the location of the image will be provided as a URL. Inside the HTML document, the image will look like this: .
Specifically, the URL points to where the image is stored. For example, if a computer image with the file name computer.jpg were stored in the images folder at www.wisegeek.com, the URL would be replaced with: . When the browser opens the web page, it displays the image in which the image tag is included.
The image tag has a number of other different attributes. They allow the user to adjust the appearance of the image on the page. The following attributes are commonly used for this tag: alt, border, size and align.
The alt attribute stands for alt text and is shown if a browser is unable to display an image. In addition, the alt text is read for those visually impaired users who choose to view text over images. For the example above, the alt text could be given as alt=”computer image”.
The border attribute adds a border to the image whose thickness depends on the indicated number of pixels. This can be especially useful when your image background and website background are similar and you want a clear distinction. For example, border=”10″ will place a 10 pixel thick border around an image.
Size attributes are also important, as width and height can be used to specify the exact size of an image. These attributes should be used very carefully, as changing them can affect the aspect ratio or quality of the displayed image. Size attributes don’t change the actual file, just how the browser displays it.
The align attribute specifies how the image is aligned relative to the text on the page. There are several choices for this attribute, including top, bottom, center, left, right, absmiddle, absbottom, baseline, and texttop. These tags also help determine how the text on the page aligns with the image.
Protect your devices with Threat Protection by NordVPN