Detailed · Deep study
1The head section
<!DOCTYPE html>
<html>
<head>
<title>Rivers Hotel</title>
<meta charset="UTF-8">
<meta name="description" content="Rooms and prices at Rivers Hotel">
<meta name="keywords" content="hotel, rooms, Mombasa">
<meta name="author" content="A Student">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/extra.css">
<base target="_blank">
</head>
<body>
<h1>Rivers Hotel</h1>
<p class="intro">Welcome to our hotel.</p>
</body>
</html>Purpose of the head and body: the head holds information about the page (title shown in the browser tab, metatags, links to stylesheets) that is not displayed in the page itself; the body holds the content that is displayed.
| Metatag | Function |
|---|---|
| charset | defines the character set (e.g. UTF-8) so text displays correctly |
| keywords | words used by search engines to find the page |
| author | the author of the web page |
| description | a description of the page, shown in search results |
| viewport | makes the page display correctly on all devices (scales to the screen width) |
2Tables and objects
<table style="width:80%">
<tr>
<th colspan="2">Room prices</th>
</tr>
<tr>
<td rowspan="2">Standard</td>
<td>$60 single</td>
</tr>
<tr>
<td>$90 double</td>
</tr>
</table>Tables are used to structure elements in rows and columns so they line up, e.g. a layout or a price list. Table and cell sizes can be set in pixels or % of the window; cells can span more than one row or column (rowspan, colspan); styles can be applied to tables.
<img src="images/pool.jpg" alt="Hotel swimming pool" width="400" height="300">
<video width="320" height="240" controls autoplay>
<source src="media/tour.mp4" type="video/mp4">
</video>
<audio controls><source src="media/welcome.mp3" type="audio/mpeg"></audio>
<div class="offer"><p>Special offer this month</p></div>
<ul><li>Free wi-fi</li><li>Breakfast included</li></ul>3Bookmarks and hyperlinks
<h2 id="contact">Contact us</h2>
<a href="#contact">Go to contact details</a>
<a href="rooms.html">Our rooms</a>
<a href="https://www.example.com" target="_blank">Tourist board</a>
<a href="mailto:book@rivershotel.com">Email us</a>
<a href="map.html" target="mapwindow">Map</a>
<a href="rooms.html"><img src="images/room.jpg" alt="Rooms"></a>| Term | Meaning |
|---|---|
| hyperlink | text or an image that, when clicked, opens another location: part of the same page, another page or file, a website, or an email |
| bookmark | a named location in a page, created with an id attribute (e.g. id="contact"), that a link can jump to with #contact |
| anchor | the <a> tag that creates a hyperlink; its href attribute gives the destination |
| target | _self (same window), _blank (new window), or a name (a window named as specified) |
| relative file path | a path from the current page, e.g. images/pool.jpg – works when the site is moved or uploaded |
| absolute file path | a full path, e.g. C:\Users\A\site\images\pool.jpg – must not be used for local files, because it will not exist on another computer or the web server |
4Exam focus
Key words: head; body; title; metatag; charset; viewport; table; colspan; rowspan; alt text; div; class; bookmark; id; hyperlink; anchor; target; relative path; absolute path.
Quick self-check
Answer in your head first, then reveal.
An absolute path points to a location on one computer (1); it will not exist when the site is uploaded/moved, so the image will not display (1).
<a href="mailto:info@abc.com">…</a> (2).
To make the page display correctly on all devices/screen sizes (1).
Gives alternative text describing the image for screen readers / if it does not load (1).
