Skip to content

← Grade 8 Computing

Exam practice

Every question from the end of every unit, with hints and answers to open. After you check an answer, mark how you did, and come back to the ones you didn’t get.

10 questions

Unit 5 · Making Web Pages

a.

Explain each term, with an example: tag, element, attribute, selector, declaration.

Answer
  • Tag: a label in angle brackets that marks part of a page, such as the opening tag <h1> or the closing tag </h1>.
  • Element: an opening tag, its content and its closing tag together, such as <h1>Bhaktapur</h1>; or an empty element such as <br>.
  • Attribute: extra information in an opening tag, a name and a value, such as href="festivals.html" in a link or alt="…" in a picture.
  • Selector: the part of a CSS rule that says which elements it styles, such as h2 (every h2) or .note (every element with class note).
  • Declaration: one setting inside a CSS rule’s braces, a property and a value, such as color: maroon;.
b.

Write the HTML for a page titled “My favorite food”, with a main heading, one paragraph about why you like it, and a bulleted list of three things that go into it.

Answer
<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8">    <meta name="viewport" content="width=device-width, initial-scale=1">    <title>My favorite food</title>  </head>  <body>    <h1>Momo</h1>    <p>I like momo because they are hot, juicy and best shared with friends.</p>    <ul>      <li>flour</li>      <li>minced vegetables or meat</li>      <li>onion, garlic and ginger</li>    </ul>  </body></html>

A bulleted list is <ul>; each thing in it is an <li>. (Any food is fine, as long as the elements are right and properly nested.)

c.

Find four mistakes in this HTML, and correct them.

<html>  <body>    <h3>Our school<h3>    <p>We have <strong>600 students.</p></strong>    <img src="school.jpg">  </body></html>
Answer
  1. <html> has no lang: write <html lang="en"> (and add the <!DOCTYPE html> line and a head with a title).
  2. The first heading should be an <h1>, and its closing tag needs a slash: <h1>Our school</h1>.
  3. <strong> and <p> cross: <p>We have <strong>600 students</strong>.</p>.
  4. The picture has no alt text: <img src="school.jpg" alt="Our school's three-storey building and its playground">.
d.

Write CSS that i. makes the whole page’s text dark gray, #333, in a sans-serif font; ii. makes every <h1> maroon; iii. gives every element of class fare a light yellow background, #fff3c4, and 8 px of space inside its border.

Answer
body {  color: #333;  font-family: sans-serif;} h1 {  color: maroon;} .fare {  background-color: #fff3c4;  padding: 8px;}

Text color and font set on body are passed down to everything inside it. Space inside the border is padding.

e.

What is the difference between padding and margin? Draw a box and label its content, padding, border and margin.

Answer

Padding is the space inside the border, between the border and the content; it is filled with the element’s background color. Margin is the space outside the border, between this box and the boxes around it; it is always see-through. The drawing has the content in the middle, then the padding round it, then the border line, then the margin outside (as in Figure 5.4).

f.

Why should HTML say what each part of the page is (heading, list, paragraph), and CSS say how it looks? Give two reasons.

Answer
  • One style sheet can style every page of a website, so a change (a new color for every heading) is made once, not on every page.
  • The content stays meaningful whatever it looks like: screen readers, search engines and phones use the HTML’s headings, lists and links, while the CSS can change for a phone, for print or for a new design without touching the content.
  • (Also: HTML files stay shorter and easier to read and correct.)
g.

A page about Dashain is written in Nepali, but its <html> tag says lang="en". The page looks fine. Who has a problem with it, and why?

Answer

People using a screen reader: it reads the Nepali text with English rules and an English voice, which comes out as nonsense. Search engines and translation tools also take the page for English, so it may not be found by people searching in Nepali. The fix is <html lang="ne">. The mistake can’t be seen on the screen, which is why it is easy to miss.

h.

Write the HTML for a table of bus fares with two columns, To and Fare, and two rows: Kathmandu, Rs 50; Banepa, Rs 60. (The fares are only an example.)

Answer
<table>  <tr> <th>To</th>        <th>Fare</th>  </tr>  <tr> <td>Kathmandu</td> <td>Rs 50</td> </tr>  <tr> <td>Banepa</td>    <td>Rs 60</td> </tr></table>

The first row has heading cells, <th>, which tell a screen reader what each column is; each row after it has the same number of <td> cells.

i.

A health post’s website lets people book a visit. On it: the “Book” button is pale green with white text; after booking, the page goes back to the home page without saying anything; the booking form forgets everything if one box is wrong; the page is in English only; and the menu is in the same place on every page. For each of the five design principles, say whether it is present or missing on this website, with the evidence. Then suggest the three most important improvements.

Answer
Principle Present or missing Evidence
Clear partly missing the Book button is hard to see (pale)
Consistent present the menu is in the same place on every page
Feedback missing after booking, nothing confirms it
Forgiving missing one wrong box wipes the whole form
For everyone missing white on pale green has low contrast; English only

Improvements: (1) after booking, show a clear message with the date, time and a booking number, and send it by SMS; (2) keep what was typed when a box is wrong, and say next to that box what to fix; (3) a darker button color with enough contrast, and the whole site in Nepali as well as English.

j.

You have made a web page for your school’s science club. Describe how you would test it with a user, and how you would use what you find.

Answer
  1. Choose a user who wasn’t involved in making it, such as a younger student or a parent.
  2. Give them real tasks: “Find out when the club meets” and “Find out how to join.”
  3. Ask them to think aloud; watch without helping or explaining, and write down where they hesitate, what they tap that doesn’t work, and what they say.
  4. Afterwards, ask what was hard or confusing.
  5. List the problems, fix the biggest first (for example, put the meeting time near the top, change link words that weren’t clear), then test again, with a new user if possible, to check the change helped. Keep notes of what was changed and why.