Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Articles Thread, Lesson : XHTML 1.0 Tutorials - Understanding Inline Images and Image Maps in HTML / XHTML; Lesson : XHTML 1.0 Tutorials - Understanding Inline Images and Image Maps A collection of 8 FAQs/tutorials tips on XHTML ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=4790


Reply
LinkBack Thread Tools Display Modes
Lesson : XHTML 1.0 Tutorials - Understanding Inline Images and Image Maps
 
 
The God Father
Developer's Avatar

Reply With Quote
 
Join Date: Jul 2008
Location: NDC
Posts: 5,425
17-10-2008, 09:04 PM
 
Lesson : XHTML 1.0 Tutorials - Understanding Inline Images and Image Maps

A collection of 8 FAQs/tutorials tips on XHTML image and image map elements. Clear answers are provided with tutorial exercises on inline images and image maps: image elements and image sizes; floating images and animated images, server-side and client-side image maps. Topics included in this collection are:
  1. What Is an IMG Tag/Element?
  2. What Are the Attributes of an IMG Element?
  3. How To Reduce the Display Size of an Image?
  4. How To Float an Image to the Right Side?
  5. What Is an Animated Image?
  6. What Is a Server-Side Image Map?
  7. What Is a Client-Side Image Map?
  8. What Is a MAP Tag/Element?
Please note that all notes and tutorials are based on XHTML 1.0 specification.
What Is an IMG Tag/Element?
A "img" element is an inline element that you can use to define an inline image to be included in a XHTML document. Here are basic rules about an "img" element:
  • "img" elements are inline elements.
  • A "img" element must have empty content.
  • A "img" element requires an attribute called "src" to specify the URL of the image file.
  • A "img" element requires an attribute called "alt" to specify the name of the image.
  • A "img" element will cause browsers to fetch the image, and displayed it inline in a paragraph block. The image name will be displayed when users mouse over the image.
Here is a simple example of an "img" element:
HTML Code:
 <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>Inline Images</title>
 </head>
 <body>
  <h4>Inline Images</h4>
  <p style="background-color: #eeeeee; padding: 8px;">
   What's the image title? 
   <img src="moonrise.jpg" alt="Moonrise"/>
   Mouse over the image to find out.</p>
 </body>
</html>
If you save the above document as inline_image.html, download this image file and view it with Internet Explorer, you will see an image embedded inline in a text paragraph as shown below:
Egypt.Com EnForum




What Are the Attributes of an IMG Element?
There are 4 commonly used attributes for an "img" element:
  • "src" - Required attribute. Used to specify the URL of the image file.
  • "alt" - Required attribute. Used to specify the name of the image.
  • "width" - Optional attribute. Used to specify the width of the image.
  • "height" - Optional attribute. Used to specify the height of the image.
Here is a tutorial example of an "img" element with all 4 attributes:
HTML Code:
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>Image Attributes</title>
 </head>
 <body>
  <h4>Inline Images</h4>
  <p style="background-color: #eeeeee; padding: 8px;">
   What is the size of this image? 
   <img src="moonrise.jpg" alt="Moonrise"
    width="69" height="91"/>
   width="69" and height="91".</p>
 </body>
</html>
If you save the above document as image_attributes.html, download this image file and view it with Internet Explorer, you will see an image embedded inline with width and height attributes in a text paragraph as shown below:
Egypt.Com EnForum

How To Reduce the Display Size of an Image?
If an image embedded inline is too big when displayed in a browser, you can use "width" and "height" attributes to reduce the image's display size. The display width and height should be proportional to the actual width and height of the image. Otherwise, the image will be displayed with a distortion.
Here is a tutorial example of images with reduced sizes:
HTML Code:
 <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>Image Sizes</title>
 </head>
 <body>
  <h4>Inline Images</h4>
  <p style="background-color: #eeeeee; padding: 8px;">
   Image with the original size: 
   <img src="moonrise.jpg" alt="Moonrise"
    width="69" height="91"/><br/>
   Image with a reduced size: 
   <img src="moonrise.jpg" alt="Moonrise"
    width="35" height="45"/></p>
 </body>
</html>
If you save the above document as image_sizes.html, and view it with Internet Explorer, you will see that the same image is displayed with two sizes as shown below:
Egypt.Com EnForum

How To Float an Image to the Right Side?
If you want to float an image to the right side of the paragraph instead of inline within a text line, you have to use the CSS property "float" to do this. The "float" property takes two values:
  • "float: left" - Specifies that the image to be floated to the left side of the paragraph.
  • "float: right" - Specifies that the image to be floated to the right side of the paragraph.
Here is a tutorial example with an image floated to the right side:
HTML Code:
 <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>Floating Image</title>
 </head>
 <body>
  <h4>Inline Images</h4>
  <p style="background-color: #eeeeee; padding: 8px;">
   <img src="moonrise.jpg" alt="Moonrise"
    width="69" height="91" style="float: right"/>
   "Moonrise" is a very simple to use, yet very accurate
   program. If you put it in your Startup folder, it will
   greet you everyday with the day's sunrise, sunset, 
   moonrise, moonset, and twilight times.</p>
 </body>
</html>
If you save the above document as floating_image.html, and view it with Internet Explorer, you will see an image floated to the right side of the paragraph as shown below:
Egypt.Com EnForum

What Is an Animated Image?
An animated image is a special image file saved in animated GIF format. When an animated image is displayed in a browser window, multiple image frames will be displayed in sequence to form a simple animation.
Here is a tutorial example with a server-side image map:
HTML Code:
 <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>Animated GIF Image</title>
 </head>
 <body>
  <h4>Animated GIF Image</h4>
  <p style="background-color: #eeeeee; padding: 8px;">
   Are you getting lots of emails these days?
   <img src="lots_of_email.gif" alt="Lots of email"/>
   I am.</p>
 </body>
</html>
If you save the above document as animated_image.html, download this animated GIF image file and view it with Internet Explorer, you will see an animated image embedded inline in a text paragraph as shown below:
Egypt.Com EnForum


What Is a Server-Side Image Map?
A server-side image map is an image inside a hyper link. The image must be defined with the "ismap" attribute in the "img" element. When a server-side image map is clicked in a browser window, the mouse coordinates will be delivered to the server by them to the end of the URL of the link in the format of "?x,y".
Here is a tutorial example with a server-side image map:
HTML Code:
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>Server-Side Image Map</title>
 </head>
 <body>
  <h4>Inline Images</h4>
  <p style="background-color: #eeeeee; padding: 8px;">
   This is a server-side image map test. 
   <a href="http://localhost/mapping?var=val">Click this
   image <img src="moonrise.jpg" alt="Moonrise"
    width="69" height="91" ismap="ismap"/>
   to see what happens.</a> Use browser back button to 
   come back.</p>
 </body>
</html>
If you save the above document as server_image_map.html, and view it with Internet Explorer, you will see an image in a hyper-link as shown below:


Egypt.Com EnForum




What Is a Client-Side Image Map?
A client-side image map is an image defined with the "ismap" attribute and the "usemap" attribute. When a client-side image map is clicked in a browser window, the browser will take mouse coordinates and map them to a predefined image map entry, to retrieve a target URL. The browser will then redirects to that URL. Here are the rules about "ismap" and "usemap" attributes:
  • ismap="ismap" - Specifies that the image is either a server-side image map or a client-side image map.
  • usemap="#mapReference" - Specifies that the image is a client-side image map, and the map is defined at the specified map reference.
Here is a tutorial example of how to define a client-side image map:
HTML Code:
 <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>Client-Side Image Map</title>
 </head>
 <body>
  <h4>Inline Images</h4>
  <p style="background-color: #eeeeee; padding: 8px;">
   This is a client-side image map test. 
   Click this image <img src="moonrise.jpg" alt="Moonrise"
    width="69" height="91" ismap="ismap" usemap="#mymap"/>
   to see what happens. Use browser back button to come 
   back.</p>
 </body>
</html>
If you save the above document as client_image_map.html, and view it with Internet Explorer, you will see an image. You can click it. But nothing will happen, because there is no map entries defined.
Egypt.Com EnForum


What Is a MAP Tag/Element?
A "map" element is special inline element that you to define map entries to be used by image maps. Here are some basic rules on "map" elements:
  • "map" elements are inline elements.
  • "map" elements can not have text contents.
  • "map" elements should have "area" elements as sub-elements.
  • A "map" element requires the "id" attribute to be specified.
  • A "map" element should have the "name" attribute specified a reference name to be used by an image map with the "usemap" attribute.
  • Each "area" element inside a "map" element defines a map entry for the browser to look up based on the mouse coordinates on the image map .
Here is a tutorial example of an client-side image map with map entries defined:
HTML Code:
 <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>Image Map Entries</title>
 </head>
 <body>
  <h4>Inline Images</h4>
  <p style="background-color: #eeeeee; padding: 8px;">
   This is a client-side image map test. 
   Click this image <img src="moonrise.jpg" alt="Moonrise"
    width="69" height="91" ismap="ismap" usemap="#mymap"/>
   to see what happens. Use browser back button to come 
   back.
   <map id="map1" name="mymap">
    <area href="http://localhost/upperLeft" 
     alt="Upper Left" coords="1,1,35,45"/>
    <area href="http://localhost/upperRight" 
     alt="Upper Right" coords="36,1,69,45"/>
    <area href="http://localhost/lowerLeft" 
     alt="Lower Left" coords="1,46,35,91"/>
    <area href="http://localhost/lowerRight" 
     alt="Lower Right" coords="36,46,69,91"/>
   </map>
  </p>
 </body>
</html>
If you save the above document as image_map_entries.html, and view it with Internet Explorer, you will see an image embedded in a paragraph. Click different parts of the image to see what happens.
Egypt.Com EnForum




Enjoy All CopryRight { SYSTEM }
__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
Reply

Articles Thread, Lesson : XHTML 1.0 Tutorials - Understanding Inline Images and Image Maps in HTML / XHTML; Lesson : XHTML 1.0 Tutorials - Understanding Inline Images and Image Maps A collection of 8 FAQs/tutorials tips on XHTML ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=4790


Bookmarks

Tags
image, images, inline, lesson, maps, tutorials, understanding, xhtml


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson : Saving Flash graphics as image files at runtime SABRAWY Articles 6 06-04-2009 05:26 PM
Enhance image overlay maps in Google Earth with altitude attributes Developer PERL 0 27-11-2008 07:57 PM
Lesson : Creating a Mirror of an Image Developer Articles 0 23-10-2008 01:58 AM
Change Threads Prefix Inline Developer Mods for 3.7.x 0 14-09-2008 09:05 PM
XHTML 1.1 - Module-based XHTML Developer Articles 0 03-09-2008 10:28 PM