9.3. Displaying an Image in WML: <img>
The <img> tag is used to add an image to a WML card. This is the same as in HTML. WAP browsers will display the text assigned to the alt attribute of the <img> tag if it cannot display the image for reasons such as file not found or image format not supported. The URL of the image file is specified with the src attribute.
The height and width attributes of the <img> tag, as their names suggested, are used to specify the height and width of an image's display area. WAP browsers may reserve some space on the screen according to the values of these two attributes when the image is still downloading, so that users can know the layout of the card. Also, WAP browsers may scale up or down the size of an image if the height and width attribute values are not the same as the image's real size.
Older WAP-enabled wireless devices can only display WBMP images. Newer ones support image formats commonly used on the web such as GIF, JPG and PNG.
This example demonstrates how to display an image in WML using the <img> tag:
<?xml
version="1.0"?>
<!DOCTYPE wml PUBLIC
"-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card
id="card1" title="Image in WML">
<p>
<img
src="smile.gif" alt="Smile" height="62"
width="60" /><br/>
Welcome
to our WML tutorial.
</p>
</card>
</wml>
The result of the above WML markup code in WAP browsers is shown below:
|
|
|
If the image file does not exist, the result will become:
|
|
|
Previous Page | Page 13 of 50 | Next Page |
- 1. WML (Wireless Markup Language) Introduction
- 2. WML Deck and Card
- 3. WML Document Structure
- 4. WML Generic Metadata: <meta>
- 5. Comments in WML
- 6. Line Breaking in WML
- 7. Font Size and Style in WML
- 8. WML Preformatted Text: <pre>
- 9. WML Images
- 10. WML Tables
- 11. WML Anchor Links
- 12. Programming Softkeys of Mobile Phones and the <do> Element
- 13. WML Template and Menu
- 14. WML Events and the <onevent> Tag
- 15. Timer and the ontimer Event
- 16. WML Event: onenterbackward
- 17. WML Event: onenterforward
- 18. WML Selection Lists and the onpick Event
- 19. WML Input Fields
- 20. WML Variables
- 21. Submitting Form Data to the Server in WML
- 22. Clearing a Saved Form in WML