HTML <img> width Attribute

Example An image with a height and a width of 42 pixels: <img src=”smiley.gif” alt=”Smiley face” height=”42″ width=”42″> Try it Yourself » The width attribute specifies the width of an image, in pixels. Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is […]

HTML <img> vspace Attribute

Example An image with a 50 pixels margin on top and bottom: <p><img src=”smiley.gif” alt=”Smiley face” vspace=”50″> This is some text. This is some text. This is some text.</p> Try it Yourself » Definition and Usage The vspace attribute specifies the whitespace on top and bottom of an image. Browser Support Attribute vspace Yes Yes Yes Yes Yes Compatibility […]

HTML <img> src Attribute

Example An image is marked up as follows: <img src=”smiley.gif” alt=”Smiley face”> Try it Yourself » Definition and Usage The required src attribute specifies the URL of the image. Note: When a web page loads; it is the browser, at that moment, that gets the image from a web server and inserts it into the page. Therefore, make […]

HTML <img> longdesc Attribute

Example Several examples of how to use the longdesc attribute: <!– The description is on the same page as the image –> <img src=”https://dwfaisalabad.com/wp-content/uploads/2017/08/DWF.png” alt=”DW.com” width=”100″ height=”100″ longdesc=”#w3htmlExplained”> <!– The description is in an external page –> <img src=”https://dwfaisalabad.com/wp-content/uploads/2017/08/DWF.png” alt=”DW” width=”100″ height=”100″ longdesc=”w3html.txt”> <!– The description is one of several within an external page –> […]

HTML <img> hspace Attribute

Example An image with a 20 pixels margin on both left and right sides: <p><img src=”smiley.gif” alt=”Smiley face” hspace=”20″> This is some text. This is some text. This is some text.</p> Try it Yourself » Definition and Usage The hspace attribute specifies the whitespace on left and right side of an image. Browser Support Attribute hspace Yes Yes Yes […]

HTML <img> height Attribute

Example An image with a height and width of 42 pixels: <img src=”smiley.gif” alt=”Smiley face” height=”42″ width=”42″> Try it Yourself » The height attribute specifies the height of an image, in pixels. Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. […]

HTML <img> ismap Attribute

Example A server-side image-map: <a href=”/action_page.php”> <img src=”dw.gif” alt=”DW” ismap> </a> Try it Yourself » Definition and Usage The ismap attribute is a boolean attribute. When present, it specifies that the image is part of a server-side image-map (an image-map is an image with clickable areas). When clicking on a server-side image-map, the click coordinates are sent to the […]

HTML <img> alt Attribute

Example An image with an alternate text specified: <img src=”smiley.gif” alt=”Smiley face”> Try it Yourself » Definition and Usage The required alt attribute specifies an alternate text for an image, if the image cannot be displayed. The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow […]

HTML <img> usemap Attribute

Example An image-map, with clickable areas: <img src=”planets.gif” width=”145″ height=”126″ alt=”Planets” usemap=”#planetmap”> <map name=”planetmap”> <area shape=”rect” coords=”0,0,82,126″ href=”sun.htm” alt=”Sun”> <area shape=”circle” coords=”90,58,3″ href=”mercur.htm” alt=”Mercury”> <area shape=”circle” coords=”124,58,8″ href=”venus.htm” alt=”Venus”> </map> Try it Yourself » Definition and Usage The usemap attribute specifies an image as a client-side image-map (an image-map is an image with clickable areas). The usemap attribute is associated with a <map> element’s name attribute, and creates a relationship between the <img> and the […]

HTML <img> align Attribute

Example Align an image in the middle of a text: <p>This is some text. <img src=”smiley.gif” alt=”Smiley face” align=”middle”> This is some text.</p> Try it Yourself » Definition and Usage The align attribute specifies the alignment of an image according to the surrounding element. The <img> element is an inline element (it does not insert a new line on a […]

HTML <img> Tag

Example How to insert an image: <img src=”smiley.gif” alt=”Smiley face” height=”82″ width=”82″> Try it Yourself » More “Try it Yourself” examples below. Definition and Usage The <img> tag defines an image in an HTML page. The <img> tag has two required attributes: src and alt. Note: Images are not technically inserted into an HTML page, images are linked to HTML […]