HTML CSS examples for HTML Tag:img
The img element allows you to embed an image into an HTML document.
The src attribute specifies the URL for the image.
The alt attribute defines the fallback content for the img element.
This content will be shown if the image cannot be displayed.
The img Element summary
Item | Value |
---|---|
Element: | img |
Local Attributes: | src, alt, height, width, usemap, ismap |
Contents: | None |
Tag Style: | Void |
New in HTML5? | No |
Changes in HTML5 | The border, longdesc, name, align, hspace, and vspace attributes are obsolete in HTML5. |
To embed an image, you need to use the src and alt attributes.
<!DOCTYPE html> <html> <head> <title>Example</title> </head> <body> <p> <img src="http://java2s.com/resources/g.png" alt="Image" width="200" height="67"> </p> </body><!--from ww w .j av a 2 s. c om--> </html>
You use the width and height attributes to set the size in pixels.