← HTML practicum

Lesson 08 · 13 steps

Images, and the frames of 1999

image.html brings pictures to the site — and with them the oldest technology in this whole practicum: frames. Half the lesson builds a layout the way it was built twenty-five years ago, which is the clearest way to see why nobody does it now.

Hand in image.html frame.html frame1.html frame2.html frame3.html 7_10.html menu.html content.html top.html menu3.html content_1.html
What the browser makes of it open on its own ↗
02A picture on the pageThe task: show an image with the img tag.code ↓
<!-- 2) зображення тегом img -->
<h2> Тег img </h2>
<img src="images/navi.jpg" width="320" alt="Natus Vincere з трофеєм DreamHack Leipzig 2016">
<p> Natus Vincere з трофеєм. Фото: Tmv23, ліцензія CC BY-SA 3.0, Вікісховище. </p>

img has no closing tag — there is nothing to put inside it. src is the file, width the size in pixels; give only the width and the height follows the proportions.

alt is the text that takes the picture's place: for someone using a screen reader, and for everyone when the file fails to load. It is not in the assignment's sample; it is in this file because a picture without it is simply missing for part of the readers.

Today

Every photograph here comes from Wikimedia Commons under a CC BY-SA licence, and the authors are named in images/CREDITS.txt. Screenshots from the game itself belong to Valve, so they are not on this site — the diagrams were drawn instead.

03The same picture through objectThe task: show an image with the object tag.code ↓
<!-- 3) зображення тегом object -->
<h2> Тег object </h2>
<object data="images/arena.jpg" type="image/jpeg" width="320"> Кіберспортивна арена </object>

object is the general-purpose «put something external here» tag: a picture, a PDF, a video. Between its tags goes what to show when the thing cannot be displayed.

04A photo galleryThe task: add five pictures to the images folder and build a gallery from them.code ↓
<!-- 4) розміри мініатюри і вікна фотогалереї -->
<style type="text/css">
.thumbnail {width:70px;height:70px}          /* мініатюра */
.frame {width:420px;height:300px;margin:5px} /* фрейм для великого малюнка */
</style>
<!-- 4) фотогалерея: мініатюри відкривають великий малюнок у фреймі -->
<h1> Фотогалерея </h1>
<a href="images/1.jpg" target="frame"> <img src="images/1.jpg" class="thumbnail" alt="команда з трофеєм"> </a>
<a href="images/2.jpg" target="frame"> <img src="images/2.jpg" class="thumbnail" alt="кіберарена"> </a>
<a href="images/3.jpg" target="frame"> <img src="images/3.jpg" class="thumbnail" alt="сцена турніру"> </a>
<a href="images/4.jpg" target="frame"> <img src="images/4.jpg" class="thumbnail" alt="гравець"> </a>
<a href="images/5.jpg" target="frame"> <img src="images/5.jpg" class="thumbnail" alt="схема карти"> </a>
<br/>
<iframe name="frame" class="frame" src="images/1.jpg"></iframe>

Each thumbnail is a link wrapped around a small copy of the picture, and target="frame" sends it to the iframe named frame at the bottom. Clicking a thumbnail changes the big picture without reloading the page.

This is a genuinely old trick, and in 2003 it was the only way to do it without a script.

Today

Note that the thumbnails are the full-size files squeezed into 70 pixels by CSS: the browser still downloads every one of them whole. A real gallery ships separate small copies — which is why pages built this way are slow on a phone.

05A picture inside a line of textThe task: show an embedded image with different alignments against the text.code ↓
<!-- 5) вирівнювання зображення відносно тексту -->
<h2> Вирівнювання малюнка в рядку </h2>
<img src="images/6.jpg" width="70" align="top"> Вирівнювання по верхньому елементу в рядку <br>
<img src="images/6.jpg" width="70" align="absbottom"> Нижня межа зображення по нижній межі рядка <br>
<img src="images/6.jpg" width="70" align="bottom"> Нижня межа зображення по базовій лінії рядка <br>
<img src="images/6.jpg" width="70" align="middle"> Середина зображення за базовою лінією рядка <br>

By default a picture sits on the text baseline, like a very large letter. align moves it: top, middle, bottom, absbottom.

Today

align is gone from HTML. The modern equivalent is vertical-align in CSS, and for a picture with text flowing around it, float — or, nowadays, a flex or grid container.

06Two framesThe task: create menu.html, content.html and frame.html, where frame.html builds two frames.code ↓
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> Фрейми </title>
</head>
<frameset cols="140,*">
  <frame src="menu.html" name="MENU">
  <frame src="content.html" name="CONTENT">
</frameset>
</html>

A frameset page has no body at all: instead it divides the window into frames, each showing a different file. cols="140,*" means a 140-pixel column and «everything else».

The link in the menu carries target="CONTENT", so the page it opens lands in the other frame.

Today

Frames were the way sites were built in the late 1990s, and they are deprecated: the address bar never changes, so a page inside frames cannot be bookmarked, shared or found by search. Browsers still render them, which is why this exercise still works at all. The modern descendant is iframe — one framed page inside a normal one.

09Three framesThe task: frame1.html with a top frame above a menu and a content area.code ↓
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> Три фрейми </title>
</head>
<frameset rows="80,*">
  <frame src="top.html" name="TOP" scrolling="no" noresize>
  <frameset cols="140,*">
    <frame src="menu.html" name="MENU">
    <frame src="content.html" name="CONTENT">
  </frameset>
</frameset>
</html>

Framesets nest: rows first, then a columns set inside the second row. noresize stops the visitor dragging the divider, scrolling="no" removes the scrollbar.

11A floating frameThe task: frame2.html showing a floating frame built from frame.html.code ↓
<!-- 11) плаваючий фрейм -->
<h2> Плаваючий фрейм </h2>
<p><iframe src="frame.html" width="420" height="160"></iframe></p>

iframe is a frame that lives inside an ordinary page — a window onto another document, with its own scrollbar. Unlike frameset it is not deprecated, and this very practicum uses it: every lesson page shows its file in one.

12TabsThe task: frame3.html with three tabs, each opening its own file.code ↓
<html>
<head> <meta charset="utf-8">
<title> Закладки </title>
</head>
<body>
<p>
<a href="rgb.html" target="tabs"> Карти </a> |
<a href="cmyk.html" target="tabs"> Зброя </a> |
<a href="hsb.html" target="tabs"> Турніри </a>
</p>
<iframe src="rgb.html" name="tabs" width="620" height="110"></iframe>
</body>
</html>

Three links and one iframe: each link loads its file into the frame by name. The assignment's sample calls the files rgb.html, cmyk.html and hsb.html, so those names stayed; the contents are about maps, weapons and tournaments, like the rest of the site.

13A menu down the leftThe task: 7_10.html with a left-hand frame, using menu3.html and content_1.html.code ↓
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> Фрейм із лівою областю </title>
</head>
<frameset cols="200,*">
  <frame src="menu3.html" name="MENU" noresize>
  <frame src="content_1.html" name="CONTENT">
</frameset>
</html>

The layout every site had in 2001: navigation pinned on the left, content on the right, and the address bar showing the same URL whatever you clicked.