Placing and decorating pictures and graphics on web pages
On a web page pictures are placed with the <img> tag of HTML: the src attribute gives the file path, alt gives a short text description of the picture, and width and height give its size (in pixels). If the picture file is in the same folder as the page, the path is just the file name; in another folder it is written like “images/club.jpg”. For the web, JPEG (photographs), PNG (transparency and crisp lines), SVG (vector, sharp even when enlarged) and the modern WebP are convenient. The file size of a picture affects page speed: to show a 4000×3000 pixel photo in a 300-pixel box it is wasteful to upload it as it is; before uploading it should be reduced to the needed size (in PhotoShop, Image → Image Size) and compressed. The look of the page is set with CSS: color – text colour, background – background, border – border, padding – inner space, margin – outer space, font-family – font, text-align – alignment; the rules are written inside <style> or in a separate .css file. Colours are given by a #RRGGBB (hexadecimal) code. The contrast between text and background must be sufficient: at least 4.5:1 is recommended for ordinary text (white text on #0b5cad is about 6.7:1, on #1e90ff only about 3.2:1, which suits only very large headings). Do not copy a picture from another site: respect copyright and use your own picture or one with a free licence.
When you put a picture in a frame and the frame is small, you shrink the picture instead of cutting it. A web page picture also has to fit screens of different sizes, so its size is set in advance.
Web designers, newspaper layout staff and photo-album makers place pictures on a page at a suitable size.
Draw one picture at the full width of a notebook page and again at half that width, and next to each write in one sentence what the picture shows.
1<!DOCTYPE html> 2<html lang="uz"> 3<head> 4 <meta charset="utf-8"> 5 <title>Maktab klubi</title> 6 <style> 7 body { font-family: Arial, sans-serif; background: #f4f8ff; margin: 0; } 8 header { background: #0b5cad; color: #ffffff; padding: 16px; text-align: center; } 9 .karta { width: 300px; margin: 20px auto; background: #ffffff; padding: 12px; } 10 img { max-width: 100%; height: auto; border: 3px solid #0b5cad; } 11 </style> 12</head> 13<body> 14 <header><h1>Informatika klubi</h1></header> 15 <div class="karta"> 16 <img src="klub.jpg" alt="Klub a’zolari kompyuter oldida" width="300" height="200"> 17 <p>Klub har juma kuni soat 15:00 da yig‘iladi.</p> 18 </div> 19</body> 20</html>
| 5 pictures, 2 MB | 5 pictures, 400 KB | |
|---|---|---|
| total | 10 MB = 80 Mbit | 2 MB = 16 Mbit |
| loading at 10 Mbit/s | 80:10 = 8 seconds | 16:10 = 1.6 seconds |
“A fast and good-looking page”: pairs reduce one large photo for the web in PhotoShop (800 pixels wide), save it as JPEG, compare its size with the original and place it on a page with alt text.