Requirements: using appropriate tools, techniques and design elements for the purpose and end users, applying appropriate data integrity and testing procedures in the development of the outcome, describing relevant implications
Relevant Implications: End user considerations
Learning Outcomes
On completion of this section you will know:
How to add an image to a web page
How to centre an image
How to put space between an image and the surrounding text
Introduction
As well as text, images, drawings and photographs can also be added to a web page. Although an essential component of any web page, images can take up a lot of storage space and in areas of poor internet access they can slow down the downloading of a page. For that reason the following guidelines should apply to images:
only images essential to the content of the web page should be included
images should be less than 1MB in size, prefereably less than 500KB
In order to allow visually impaired users to get the most out of the web page, any images with content relevant to the page's topic should be described in full in the image's alt attribute
Adding Images
For demonstrating adding images to a page we shall use the same layout as in the previous example. We effect this by using the same cascading stylesheet as we did before but will add extra formatting commands to it, to take care of the images.
The structure of the above code is similar to that of the previous code. the <head>/</head> section contains the title of the page as well as linking to the cascading stylesheet. The <body>/</body> contains the blocks <header>/</header>, <main>/</main>, and <footer>/</footer>. The theme of the page has slightly altered. Here we are concentrating on Wellington, and especially on the picturesque buildings in that city. For the sake of brevity we have included only two buildings and a very short textual description of each.
The two article elements within the <main>/</main> tags have identical layout. The first, which spans lines 12 to 18, begins with a level 3 heading at line 13.
Line 14 defines an img element. The src attribute of this element specifies the name of the file whose image we wish to display. The alt attribute provides a verbal description of the image. This verbal description will never be seen on the web page unless the image cannot be displayed, in which case it is displayed in the position which is allocated to the image itself. It's other use, however is to give a better user expreience to visually impaired people. The screen reading software used by the visually impaired cannot interpret images and when they encounter such an element, they will search for the alt attribute and if they encounter it, they will read out its content. For this reason it is important to add detailed description of the image to the alt attribute.
At line 15 we meet a new element figcaption. This is one of a number of inline formatting elements within html. It is generally used when you want to give a special formatting to short blocks of text or to individual words. In this case we shall use it to provide footers for images.
There are no new elements or concepts introduced in this section. Also the explanation we have provided for the article's contents, also apply to the second one, and so there is no need to discuss it.
The two new elements introduced img and figcaption require formatting and thus we shall look at the attached CSS file next
The first 25 lines of Listing 2 should be familiar to us already and so we shall start at line 26 where we specify the formatting of the img elements. The image is to take up 80% of the width of its container. The width of the main element is 800 pixels and since we have not specified any any width for the article elements they must also be 800 pixels wide since they are contained within the main element. The width of our img elements will be 640 pixels.
Setting the display attribute to block and the margin attribute to auto means that the image will be centered within its container.
Finally we shall look at the formatting of our figcaption element, whose definition spans lines 31 to 36. As far as the text formatting is concerned lines 31 and 32 specify that the text will be bold and small size. Lines 33 and 34 specify that figcaptionelement will be centered on the page, while line 35 specify that there will be a 10 pixel space between the figcaption element and whicheve element is directly above it.