<img src="mycoolpic.gif"
align="position" |
Blank space bordering left and right side Blank space bordering top and bottom |
align attribute with the img element. Example 1 - SOURCE CODE
<p>
<img src="mycoolpic.gif" align="left">...some text...
</p>
Example 1 - RESULT
This image's
alignattribute is set toleft. The image 'floats' to the left as the text wraps around the right of the image. It will continue to do so as long as the block element which contains both the image and the text is not terminated by its end tag. As the text continues past the bottom border of the image, it re-aligns itself with the original left margin.
Example 2 - SOURCE CODE
<p>
<img src="mycoolpic.gif" align="right">...some text...
</p>
Example 2 - RESULT
This image's
alignattribute is set toright. The image 'floats' to the right as the text flow wraps around the left of the image.
Line breaks can be created using thebrelement. As the text continues past the bottom border of the image, it flows as it would normally to the original right margin.
Example 3 - SOURCE CODE
<p>
<img src="mycoolpic.gif" align="left">...some text... <br clear="all">...some more text clearing the bottom...
</p>
Example 3 - RESULT
Here's another example of an image's
alignattribute set toleft. The image 'floats' to the left as the text flow wraps around the right.
Using thebrelement with theclear="all"attribute-value pair you can cause the text that follows to continue on the first line that clears the bottom of all floating objects (in this case,mycoolpic.gif).
align attribute are: top, middle and bottom which control the layout of your graphic with respect to the current text line or baseline. (The baseline is the imaginary horizontal line that your text rides on.) The following examples will illustrate:Example 4 - SOURCE CODE
<img src="mycoolpic.gif"
align="top, middle, or bottom">
Example 4A - RESULT
This image's
alignattribute is set totop. The text aligns with the top of the image.
Example 4B - RESULT
This image's
alignattribute is set tomiddle. The text aligns with the vertical center line of the image.
Example 4C - RESULT
This image's
alignattribute is set tobottom. The text aligns with the bottom of the image or more specifically the image rides on the baseline of the text. This is the default setting when noalignattribute is declared in the<img>tag.
hspace and the vspace attributes you can control how much blank space or white space to display around your images. The following examples illustrate:Example 5 - SOURCE CODE
<p>
...some text... <img src="mycoolpic.gif" align="left" hspace="20" vspace="30"> ...some more text...
</p>
Example 5 - RESULT
This image has itsalignattribute set toleftwhich floats the image to the left and causes the text to wrap around the right.In addition to this, the
hspaceand thevspaceattributes are used whose values represent lengths in pixels. Thehspaceattribute defines how much white space to allot on either side of the image while thevspaceattribute defines how much white space to allot on the top and bottom of the image. In this example, 20 pixels of white space border on the left and right side of the image respectively while 30 pixels of white space border on the top and bottom of the image.
<img> tag within the <center>...</center> tags:
Example 6 - SOURCE CODE
...some text...
<center><img src="mycoolpic.gif" vspace="10"></center>
...some more text...
Example 6 - RESULT
This image is placed in the center of the page using thecenterelement. The text does not wrap around the image. All text that appears before the<img>tag in the source code will be displayed on top of the image.All text that appears after the <img>tag in the source code will be displayed below the image. You can use thevspaceattribute to implement some fine control of the white space on the top and bottom of the image.
NOTE:
In all of the above examples I have omitted using thealt,widthandheightattributes for the purposes of clarity. This is not in any way, shape or form meant to diminish their importance. See Using Graphics - Accessibility for more information.
Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates
See also:
If you need a .COM web address, you can get one quick and easy at...
| <~BACK | TOP | NEXT ~> |