All images should be sized appropriately in both physical dimensions (width & height) and resolution, creating an image which has the smallest file size possible. Read the post Editing images for your website for more help.

All of your image tags must have:

  • the correct src attribute,
  • the width and height attributes,
  • alt text.
<!-- the default unit for width and height is pixels -->
<img src="ice-cream.png" width="400" height="200" alt="A selection of mouth-watering, artisanal gelati." />

Image borders

You can add a border around the image using the border attribute:

<!-- use integers for the border value - the higher the value the thicker the border -->
<img src="" width="" height="" alt="" border="1" />

Wrapping text

Text can and should be wrapped around images where appropriate. Doing this correctly also counts towards the mark for the correct use of white-space on your web-pages.

Images and paragraphs are both block-level elements. This means they will automatically never occupy space next to each other — the one will always be above the other. To change this, we can use the align attribute for the <img> tag:

<img src=”ice-cream.jpg” align=”right” />
<p>This paragraph of text flows on the left of the image - the image will appear to float on the righ-hand side of the page.</p>

See the Pen HTML Images by David Fox (@foxbeefly) on CodePen.light

Again: CSS offers far more effective techniques to achieve this type of formatting.

Background images

Background images can be problematic in web design as they are often difficult to execute on multiple different screen sizes (or “view portals”). They also often negatively affect the readability of text when the image is not suitable.

Tiling (repeating the same image horizontally & vertically to fill an area) a small image file to create texture effect can be effective. A small image will be tiled automatically.

If you do use an actual picture in the background, once again it may be necessary to use image-editing software such as GIMP to ensure text is legible by changing its opacity (make the picture look faded).

A background image can be added using the following HTML:

<body background="bgimage.gif">

See the Pen HTML background image by David Fox (@foxbeefly) on CodePen.light

Of course, CSS offers much more control and many more options. Read my CSS primer here.

By MisterFoxOnline

CAT Educator

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.