Links, Images and Tables
We enrich a web page with hyperlinks, images and tables. Using the `a`, `img` and `table` tags we learn to move between pages and show data in a table.
All topics (10 of 11)
Chapter 1. Computer networks
Chapter 2. Information security
Chapter 3. Creating web pages
The hyperlink is the foundation of the web. It is created with the <a> (anchor) tag, and the address goes in the href attribute: <a href="https://informatik.uz">Informatik.uz</a>. The text inside the tag appears on the page as a link. To go to another page of your own project a relative address is enough: <a href="about.html">About us</a>. To open a link in a new window, add the attribute target="_blank".
An image is inserted with the <img> tag. It has no closing pair and has two important attributes: src is the address of the image file and alt is text that describes the picture: <img src="logo.png" alt="School logo" width="200">. The alt text appears if the picture fails to load and is read aloud by screen readers for visually impaired users. JPG, PNG and WebP are common web formats.
A table is created with the <table> tag. Each row is written in <tr>, a heading cell in <th> and an ordinary cell in <td>: <tr><th>Subject</th><th>Grade</th></tr>, then <tr><td>Informatics</td><td>5</td></tr>. The attributes colspan and rowspan stretch a cell over several columns or rows. A table is used only to show data, not to lay out a page.
Using these tags together, you can build a small multi-page site: the home page has a menu made of a list of links (<a> inside <ul>), and the other pages have images and tables. Write file names in lowercase Latin letters without spaces (dars-jadvali.html), because servers distinguish letter case. Check that the links work by opening the page.
Key takeaways
- A link is written as
<a href="address">text</a>. - An image is inserted with
<img src="…" alt="…">; thealttext matters. - A table is
<table>, a row is<tr>, a heading cell is<th>, a cell is<td>. - Write file names in lowercase Latin letters without spaces.
Practice tasks
- Create two pages (
index.htmlandabout.html) and link them to each other. - Add an image to a page with
altandwidthattributes; spell the image file name wrong on purpose and see how thealttext appears. - Build a timetable with
<table>of 3 columns and 4 rows (day, subject, room).
Review questions
Test yourself: think first, then reveal the answer.
1What is the `alt` attribute in the `<img>` tag for?Show answerHide answer
If the picture does not load this text appears, and for visually impaired users the description of the image is read aloud.2How do the `<th>` and `<td>` tags differ in a table?Show answerHide answer
`<th>` is a heading cell (usually bold and centred) and `<td>` is an ordinary data cell.
0 of 11 topics completed
Sign in to mark