Additional IMG Tag Attributes

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

Next to the pointer a "tool tip" pops up containing the words from the alt attribute.

Additional IMG Tag Attributes

One way to center an image is to bracket it with the div tag like this:

<div align="center">
<img src="petrock.jpg"  alt="Pet Rock" />
</div>

If you want the image to be positioned to the left of the page and for text to fill the area to the right of it, use the align attribute within the img tag. The tag should be followed by the text that will fill the area not used by the image:

<img src="petrock.jpg"  alt="Pet Rock" align="left" />
<p>
This text will appear to the right of the
image.
It may look a bit cramped.
We will get to that in a bit.
</p>

<p>
You may have as many paragraphs here as you want.
After the area to the right of the image is filled,
the rest of the words will
fill the full width of the page,
as usual.
</p>

Here is what the above does on your browser:

Pet Rock

This text will appear to the right of the image. It may look a bit cramped. We will get to that in a bit.

You may have as many paragraphs here as you want. After the area to the right of the image is filled, the rest of the words will fill the full width of the page, as usual.



After the last paragraph positioned by an image it is often useful to include the tag <br clear="all" />. This says to stop filling the area to the right of the image and to resume using the full page for text.



QUESTION 3:

How would you write a tag that puts the image on the right and text to the left of it?

<img src="petrock.jpg"  alt="Pet Rock" align="__________ /">