Skip to content
Cambridge IGCSE0417

Web development layers

Information Communication Technology 0417 Chapter Notes

What this chapter covers

Web development layersCreate a web pageUse stylesheets
ShareWhatsAppPost
Web development layers notes

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Web development layers notes as text: skim, search, and jump between subtopics.

~24 min read

1. The three layers

A web page is built in three web development layers. Each layer has its own job.

The content layer enters the content and creates the structure. The presentation layer displays and formats the elements. The behaviour layer uses a scripting language to control the elements.

Name the layer, then describe what it does. A name is not a description.

Examiner insight

“Many candidates could give the name of the layer rather than describing it.” “Many candidates wrote about the systems life cycle or stages of it such as of design, develop or test.”

Worked example 12 marks

A web page uses a stylesheet.

(b)(i) State the web development layer where HTML is used.

(ii) State the web development layer where a stylesheet is used.

  1. 1

    (i) HTML is used in the content layer (structure is also accepted) [1]

  2. 2

    (ii) a stylesheet is used in the presentation layer (style is also accepted) [1]

2. The content layer

The content layer is used to enter the content and create the structure of a web page. The content is the text and images of the page. HTML is used in this layer.

Saying only that it lets you enter content repeats the name of the layer. Say what is entered, and say that the layer creates the structure.

Examiner insight

“A number of candidates said it let you enter content hence achieved no credit as they repeated the stem of the question.” “Many candidates wrote hypertext markup but few managed to gain the second mark.”

Worked example 13 marks

The text and the table of a web page are typed in by the designer. State the web development layer used. Describe the purpose of this layer.

  1. 1

    the content layer [1]

  2. 2

    it is used to enter the content, here the text, of the web page [1]

  3. 3

    and to create the structure of the web page, here the table [1]

3. The presentation layer

The presentation layer is used to display and format elements within a web page.

A stylesheet is used in this layer. It sets the style of the elements.

The name is misleading. This layer is not 'what the audience sees'. It is the layer that formats the elements.

Examiner insight

“This part was not answered as well as part (a) as many candidates thought that this layer was what the audience saw, probably derived from the name – presentation.” “Those that seemed to know what a style sheet was, were unable to explain the term without using the words ‘style’ and ‘sheet’.”

Worked example 13 marks

A designer changes the font and the background colour of every page. State the web development layer used. Describe the purpose of this layer.

  1. 1

    the presentation layer [1]

  2. 2

    it is used to display elements within a web page [1]

  3. 3

    and to format elements within a web page [1]

4. The behaviour layer

The behaviour layer is for a scripting language to control elements within a web page.

The content layer holds the elements and the presentation layer formats them. The behaviour layer is the one that controls them.

Do not give the behaviour layer for anything typed into a web page. It is the answer only where a script controls an element.

Examiner insight

“Where candidates performed well, a significant number identified the answer to part (b) as the behaviour layer rather than the content layer.”

Worked example 12 marks

A designer adds a script to a web page. State the web development layer used and describe its purpose.

  1. 1

    the behaviour layer [1]

  2. 2

    a scripting language is used to control elements within a web page [1]

5. Attached stylesheets and inline styles

A style can be set in two places in the presentation layer. An attached stylesheet is a separate file, linked in the header of the web page. An inline style attribute is written in the web page, at the position where it is needed.

An attached stylesheet applies to the whole page and is easier to reuse on many pages. An inline style has to be entered each time it is used. If the two disagree, the inline style has the higher priority.

Examiner insight

“The best answer was that an inline style attribute had a higher hierarchy than an external stylesheet.”

Worked example 14 marks

A web page uses a stylesheet.

(a) Explain the differences between attached stylesheets and inline style attributes.

  1. 1

    attached is loaded separately from the web page / inline is written in the web page [1]

  2. 2

    attached is applied to the whole web page / inline is usually at the position where it is needed [1]

  3. 3

    attached is easier to reuse on many pages / inline has to be entered each time it is used [1]

  4. 4

    inline has the higher priority [1]

Recap

  • There are three web development layers: content, presentation and behaviour.
  • Content layer: enter the content and create the structure of a web page. HTML is used here.
  • Presentation layer: display and format elements within a web page. A stylesheet is used here.
  • Behaviour layer: a scripting language controls elements within a web page.
  • An attached stylesheet is a separate file, linked in the header and applied to the whole page.
  • An inline style is written in the web page and has the higher priority.
  • Name the layer, then describe it. Do not repeat the question.

6. Head and body sections, metatags

A web page has two sections. The head section holds the page title, links to external stylesheets, metatags and the default target window. The body section holds the content the user sees.

The page title is shown in the browser. Metatags describe the page. `charset` defines the character set. `description`, `keywords` and `author` give the summary, the search words and the writer. `viewport` makes the page display on all devices.

``` <head> <title>Skirting by Sam</title> <meta charset="utf-8"> <meta name="keywords" content="skirting,architrave,joinery"> <meta name="viewport" content="width=device-width, initial-scale=1"> <base target="_blank"> <link rel="stylesheet" href="style.css"> </head> ```

Examiner insight

“The use of the metatags appeared to be more challenging with a significant number of typographical errors included within the candidates’ syntax. The most common was the use of the singular ‘keyword’ rather than keywords.” “Some did not place the base tag and target attribute in the head section and a small number of candidates omitted the underscore from the target window name.”

Worked example 14 marks

Pat's Pocket Doors is a business. Write the markup for the head section of its web page so that the page title is Pat's Pocket Doors, the character set is utf-8, search engines are given the keywords doors, pocket and sliding, and links open in a new window by default.

  1. 1

    `<title>Pat's Pocket Doors</title>` inside the head section [1]

  2. 2

    `<meta charset="utf-8">` [1]

  3. 3

    `<meta name="keywords" content="doors,pocket,sliding">` (`keywords`, not `keyword`) [1]

  4. 4

    `<base target="_blank">` as the default target window [1]

7. Tables

A table is built from rows `<tr>`, header cells `<th>` and data cells `<td>`. Tables structure the web page. They keep the display constant and make the output independent of the browser. A table can also combine different text alignments on the page.

Sizes are set in pixels or in per cent, for the table and for a cell. `colspan` makes a cell span more than one column. `rowspan` makes it span more than one row. Both go in the `<td>` or `<th>` tag, not in `<tr>`. A border value of 0 hides the borders.

``` <table width="85%" border="0"> <tr><td colspan="2">A</td></tr> <tr><td rowspan="2">B</td><td>C</td></tr> <tr><td>D</td></tr> </table> ```

Examiner insight

“Many candidates did not include the markup to not display table borders on the final web page.” “This instruction required candidates to switch on the borders for both the table and each element of table data in both the HTML and CSS.”

Worked example 13 marks

A student is creating a web page that contains tables. Explain three reasons for using tables in the web page.

  1. 1

    To structure the web page [1]

  2. 2

    To ensure the display remains constant [1]

  3. 3

    To make the output independent of the browser [1]

8. Images, video and sound

Objects placed in a web page include text, images, sound clips and video. Every image needs alternate text that describes it. Alternate text is used if the image does not display and by users who cannot see it.

Set an image's size with an inline style such as `style="width:100%"`. For video, use the `<video>` tag with a separate `<source>` tag that holds `src` and `type`. Add `controls` to display the controls, `autoplay` to start it and `loop` to repeat it. Put the error message between `<video>` and `</video>`. It tells the user why the video does not play.

``` <img src="banner.jpg" alt="Pocket doors fitted in a kitchen" style="width:100%"> <video height="640" controls autoplay loop> <source src="tour.mp4" type="video/mp4"> Your browser does not support this video. </video> ```

Set only the height, here 640 pixels, and the aspect ratio is maintained.

Examiner insight

“Some candidates erroneously set their error message as part of an alt attribute (which is not used with the video tag) or did not place the error message between the <video> and </video> tags.” “The alt text attribute should contain text that is used by a reader to describe the image which is often used for the partially sighted or in the event of an image failing to display in the browser.”

Worked example 14 marks

Place the video file tour.mp4 in a web page. The controls must be visible and the video must play automatically. Display a text message if the browser does not support the video type.

  1. 1

    `<video>` tag used (not `<object>`) [1]

  2. 2

    `controls` and `autoplay` attributes set [1]

  3. 3

    `<source src="tour.mp4" type="video/mp4">` [1]

  4. 4

    Error message placed between `<video>` and `</video>` [1]

9. Text styles, lists, div and classes

Text is tagged to give it a pre-defined style: `<h1>`, `<h2>` and `<h3>` for headings, `<p>` for a paragraph and `<li>` for a list item. Text set in style h2 sits between `<h2>` and `</h2>`. `<br>` puts the text after it on a new line.

List items sit inside `<ol>` for an ordered list or `<ul>` for an unordered list. `<div>` groups elements so a style or a class can be applied to all of them. A class is named in the page, `<div class="offer">`, and its style is set once in the stylesheet.

``` <h2>Web page created by<br>A Student 1234 5678</h2> <ul> <li>Oak</li> <li>Glass</li> </ul> ```

Examiner insight

“A small number of candidates overwrote the style h2 from the stylesheet with additional inline style attributes.”

Worked example 13 marks

Enter in cell C the text Web page created by. Enter on a new line, your name, centre number and candidate number. Set all this text in style h2.

  1. 1

    Text Web page created by in the cell [1]

  2. 2

    Name and numbers on a new line, for example with `<br>` [1]

  3. 3

    All the text set in style h2 [1]

10. Bookmarks

A bookmark in a browser is a place holder for a web page. It stores the URL so the user can reach the page again quickly. It saves a link to the page, not the page itself.

A bookmark inside a web page is made with an `id` attribute on the element to jump to. A hyperlink then points to it with `#` and the same id.

``` <h1 id="Top">Fitter Flooring</h1> <a href="#Top">Return to top</a> ```

Copy the name exactly, capitals included.

Examiner insight

“Too many described a bookmark as ‘saving a website’ or ‘saving a web page’ instead of describing the saving of a link to that website or web page.” “Some candidates did not follow the capitalisation for the name of the anchor as given in the question paper whilst other candidates were not able to create an anchor using the correct format.”

Worked example 12 marks

A web page can be bookmarked. Explain what is meant by a bookmark in the context of web pages.

  1. 1

    It is a place holder for a web page [1]

  2. 2

    It stores the URL in the browser [1]

13. File paths and stylesheets

A relative file path gives the place of a file from the page that uses it, such as `images/logo.jpg`. An absolute file path gives the full location of a file on one computer, such as `C:\Users\Sam\site\images\logo.jpg`.

An absolute path works on the author's computer only. It fails on a web server, so never use one for a link to a locally saved page or object.

Attach an external stylesheet in the head with a relative path. The order in which stylesheets are attached matters.

``` <link rel="stylesheet" href="css/style.css"> ```

Examiner insight

“Some candidates included file paths which would not work when the web page was placed on a different computer unless it had an identical file/folder structure for these files.” “If the stylesheets are not attached in the correct order the web page will not display as expected in the web browser.”

Worked example 13 marks

A web designer links a page to a picture with src="C:\Users\Mia\site\cat.jpg". It displays on her computer but not when the site is uploaded to a web server. Explain why, and give the corrected attribute. The picture is in the same folder as the page.

  1. 1

    The path is an absolute file path to her computer [1]

  2. 2

    The web server does not have that folder structure, so the file is not found [1]

  3. 3

    `src="cat.jpg"` as a relative file path [1]

Recap

  • Head: title, stylesheets, metatags, default target window. Body: the content.
  • Metatags: charset, description, keywords (plural, single words), author, viewport.
  • Tables structure the page and keep the display constant. `colspan` and `rowspan` go in the cell tag. Border 0 hides borders.
  • Images need alternate text that describes them. Video: `<video>`, `<source>` with `src` and `type`, `controls`, `autoplay`, error message between the tags.
  • Headings h1 to h3, p, li, ol, ul, div and class. Do not overwrite a stylesheet style with inline styles.
  • A bookmark stores a URL. An id attribute marks a place in a page and `#` links to it.
  • An anchor links to a location on the same or a different page. Link text or an image to a page, a URL or `mailto:`.
  • Use relative file paths, never absolute, for local pages and objects.

14. CSS and the presentation layer

A web page is built in layers. HTML is used in the content layer, which holds the structure of the page. A cascading stylesheet (CSS) is used in the presentation layer, which holds the style.

Styles are saved in cascading stylesheet format: a text file whose name ends `.css`. Do not confuse `.css` with `.csv`, a spreadsheet data file.

Examiner insight

“The candidates that achieved more than one mark usually did it by mentioning the presentation layer.” “A number confused .css with .csv and gave answers about spreadsheets.”

Worked example 12 marks

State the web development layer where HTML is used.

State the web development layer where a stylesheet is used.

  1. 1

    Content / structure [1]

  2. 2

    Presentation / style [1]

15. Attaching a stylesheet

A stylesheet is attached to a web page in the head section of the HTML. The line names the file: `<link rel="stylesheet" href="styles.css">`.

Use a relative file path: only the file name, when the stylesheet is in the same folder as the page. A path that names drives and folders on your own computer works there only. It fails on another computer, or on a web server, where the file / folder structure is different.

Examiner insight

“A few candidates did not place the stylesheet in the head section of the document or included an absolute file path within this, which would not work when the webpage was placed on a different computer unless it had an identical file/folder structure for these files.” “Some candidates erroneously included a file path which enabled the file to be attached on their computer but would not work when uploaded to a web server.”

Worked example 11 mark

Attach the stylesheet j2632.css to your web page.

  1. 1

    `j2632.css` attached in head section [1]

16. Writing the stylesheet

The stylesheet holds CSS only. No HTML goes in it. Each rule gives a selector such as `h1`, `h2`, `h3`, `p` or `li`, then the settings in braces. A setting is a property, a colon, a value and a semicolon.

A comment starts with `/*` and ends with `*/`. Put your details in a comment where the question says, usually at the start of the file.

``` /* Name, centre number, candidate number */ p { color: #000099; } ```

Examiner insight

“The CSS comment was not always set using /* */ and was sometimes seen at the end of the stylesheet or after the body {} selector rather than at the start.” “A number of candidates included HTML in their stylesheet despite clear instructions not to do so.”

Worked example 13 marks

Create a stylesheet that sets the text colour of style p to #000099. Put your name in a comment at the start of the stylesheet.

  1. 1

    comment `/* your name */` at the start of the stylesheet, not HTML [1]

  2. 2

    selector `p` with its settings in braces `{ }` [1]

  3. 3

    `color: #000099;` [1]

17. Font properties and colours

`font-family` lists the fonts in the order the question gives, so the browser can choose from the list. Put speech marks round a font name of several words, such as `"Trebuchet MS"`. Do not put them round the generic `sans-serif` or `serif`. Capitalise font names: `Arial`, `Verdana`.

Set the size in points: `font-size: 20pt;`. Set colours as a hexadecimal code with a `#`. Alignment is `text-align: center;`, spelt `center`. Bold and italic are `font-weight: bold;` and `font-style: italic;`.

When styles share settings, use one combined selector:

``` h1, h2 { font-family: "Trebuchet MS", Arial, sans-serif; font-size: 20pt; color: #000099; text-align: center; } ```

Examiner insight

“Some candidates erroneously placed the generic font style sans-serif in speech marks. A considerable number of candidates set the font-size in px not pt.” “A number of candidates ignored the instruction that all colour codes must be in hexadecimal, some using the colour word blue and others omitting the # to inform the browser the following characters are in hex.”

Worked example 12 marks

Attach the stylesheet j26skirting.css to your web page.

Edit this stylesheet so that style h1 has a font-size of 20-point.

  1. 1

    `j26skirting.css` attached in head section [1]

  2. 2

    the 60 px in style `h1` changed to `font-size: 20pt;`, so 20 pt [1]

18. Backgrounds and tables

Set the page background in the `body` selector: `background-color: #...;`. A colour code is red, green, blue in that order. Swap the pairs and the colour changes.

Table settings go in the `table` selector: width, `border-spacing`, `border-collapse` and the margins. Cell settings go in the `td` selector: padding and borders. To centre the table in the window use `margin-left: auto;` and `margin-right: auto;`. `text-align` would move the text inside the cells instead.

To hide the borders, set `border: 0;` in both `table` and `td`.

Examiner insight

“Few candidates placed the padding in a single td selector. A significant number of candidates erroneously included the cell padding in the table selector.” “Some candidates incorrectly centred the contents of the table rather than centring the table in the web browser.”

Worked example 14 marks

In the stylesheet, set the table to a width of 85%, centre it in the browser window and make sure no borders show.

  1. 1

    `table { width: 85%; }` [1]

  2. 2

    `margin-left: auto;` and `margin-right: auto;` in the `table` selector [1]

  3. 3

    `border: 0;` in the `table` selector [1]

  4. 4

    `border: 0;` in the `td` selector as well [1]

19. Inline styles, attached sheets and priority

An attached stylesheet is a separate file, applied to the whole web page and easy to reuse on many pages. An inline style attribute is written in the web page, at the position where it is needed: `<img src="logo.png" style="width:100%">`. It has to be entered each time it is used.

When the two disagree, the inline style has the higher priority. With several attached stylesheets, the one attached later has the higher priority. Extra styles in the head or inline, or styles an editor adds itself, can overwrite the attached stylesheet.

Examiner insight

“The best answer was that an inline style attribute had a higher hierarchy than an external stylesheet.” “Some candidates did not attach the stylesheets in the correct order so that the new stylesheet had higher priority than m25plaster.css.”

Worked example 14 marks

A web page uses a stylesheet.

Explain the differences between attached stylesheets and inline style attributes.

  1. 1

    Attached is loaded separately from the web page / inline is written in the web page [1]

  2. 2

    Attached uses a separate file / inline is part of the web page code [1]

  3. 3

    Attached is applied to the whole web page / inline is at the position where it is needed, for specific text [1]

  4. 4

    Attached is easier to reuse on many pages / inline has to be entered each time it is used [1]

20. A style and a class

A style is a rule for an HTML tag, such as `h2` or `p`. It applies to every such tag in the page.

A class is a rule with a name of your own, written `.name` in the stylesheet. It applies only to the tags that are given that class: `<h2 class="name">`. Use a class when only some of the tags must look different.

Examiner insight

“Many candidates found this question challenging, sometimes setting class as an attribute of a different HTML tag rather than to <h2>.” “Some candidates set the class to an auto-style created by the editor rather than the style that had been provided in the stylesheet attached to the web page.”

Worked example 13 marks

A web page has three paragraphs. Only the second paragraph must be red. Explain why style p is not used, and how a class is used instead.

  1. 1

    style `p` applies to every paragraph, so all three would turn red [1]

  2. 2

    in the stylesheet: `.alert { color: #FF0000; }` [1]

  3. 3

    in the HTML: `<p class="alert">` on the second paragraph only [1]

Recap

  • CSS is used in the presentation layer. HTML is used in the content layer.
  • Save styles as a `.css` file. It holds CSS only, with any comment in `/* */` at the start.
  • Attach the stylesheet in the head section, with a relative file path.
  • Fonts: speech marks round several-word names, none round `serif`; size in `pt`; colour in hexadecimal with `#`.
  • Padding goes in `td`. Table width, spacing and margins go in `table`. Switch borders off in both.
  • An inline style attribute has a higher priority than an attached stylesheet. A later attached sheet beats an earlier one.
  • A style applies to every such tag. A class applies only to the tags given its name.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. State the web development layer where HTML is used.1 mark
  2. State the web development layer where a stylesheet is used.1 mark
  3. State the web development layer that uses a scripting language to control elements within a web page.1 mark
  4. Describe the content layer.2 marks
  5. A designer changes the colour of every heading in a web page. State the layer used and give a reason.2 marks
  6. State the web development layer used for each task. (a) Typing the paragraphs and building the table. (b) Setting the background colour. (c) Adding a script that controls an element.3 marks
  7. Explain two differences between an attached stylesheet and an inline style attribute.2 marks
  8. A school has 20 web pages that must all use the same fonts and colours. Which method should the designer use? Give two reasons.3 marks
  9. A chess club has a web page. An attached stylesheet makes every heading green. A member then does four tasks, in this order. 1. Types a new heading into the web page. 2. Adds an inline style attribute to the new heading to make it orange. 3. Edits the attached stylesheet so that every heading is purple. 4. Adds a script that controls the new heading. (a) State the web development layer used for each of the four tasks. (b) State the colour of the new heading after task 3. Explain your answer.6 marks
  10. A museum has a website of 30 web pages. A student writes these three statements about it. A. 'The presentation layer is what the visitor sees.' B. 'The script that controls the picture is in the content layer, because it is typed into the web page.' C. 'All 30 pages use the same colours, so the best method is an inline style attribute in every heading.' Each statement contains a mistake. For each statement, identify the mistake and give the correct statement.6 marks
  11. State which section of a web page holds the page title.1 mark
  12. A bakery wants search engines to find its web page. Write the metatag that gives the keywords bread, cakes and pastries, and state the section of the page it is placed in.2 marks
  13. Explain the function of an anchor.2 marks
  14. Write the markup for a table data cell containing the text Menu that spans two columns.2 marks
  15. Explain why an absolute file path must not be used in a hyperlink to a web page saved in the same site.3 marks
  16. Write the markup to place the image logo.png. Use an inline style attribute to set its width to 50%. Include alternate text for a school badge.3 marks
  17. The heading Welcome is in style h1 at the top of a long web page. Write the markup that makes this heading a bookmark called Top. Then write the markup that makes the text Return to top, at the foot of the page, a link back to the bookmark.3 marks
  18. Write the markup to make the text Contact us a link to an email editor to prepare an email to info@school.org with the subject line Trip.3 marks
  19. A cycle club's web page is built with a single table. The table must fit 80% of the browser window and its borders must not be visible. The first column holds one cell, A, that is the full height of the table. The second column holds three cells, B, C and D, one under the other. Write the markup for the table, using the letters as the cell contents.5 marks
  20. A student wrote this markup for a web page. The page and the folder css are saved in the same folder. Links must open in a new window called _blank by default. The link at the foot must return to the heading. A message must appear if the browser does not support the video. ``` <head> <title>Harbour Kayaks</title> <meta name="keyword" content="kayak,hire,harbour"> <link rel="stylesheet" href="C:\Users\Lee\site\css\kayak.css"> </head> <body> <base target="blank"> <h1 id="Top">Harbour Kayaks</h1> <video controls alt="Video not supported"> <source src="tour.mp4" type="video/mp4"> </video> <a href="#top">Return to top</a> </body> ``` Identify six errors and correct each one.6 marks
  21. State the web development layer where a stylesheet is used.1 mark
  22. A stylesheet is saved in cascading stylesheet format. State the ending of its file name.1 mark
  23. A web page and its stylesheet `layout.css` are in the same folder. Write the line of HTML that attaches the stylesheet and state which section of the page it goes in.2 marks
  24. Explain why a relative file path is used when attaching a stylesheet.2 marks
  25. Write the CSS rule that sets style h2 to the font Verdana, with sans-serif as the generic font, 18 points, centre aligned.3 marks
  26. In a stylesheet, set the space between table cells to 8 pixels and the space inside each cell to 15 pixels.2 marks
  27. Write one rule that gives styles h1, h2 and h3 the font Palatino Linotype, with serif as the generic font, and the colour dark red #990000.4 marks
  28. The attached stylesheet sets p to blue text. One paragraph in the web page is written `<p style="color:red">`. State the colour of that paragraph and give the reason.2 marks
  29. A stylesheet must set styles h1 and h2 to the font Gill Sans, then Arial, then a generic sans-serif font. The text must be 24 points, colour #0033CC and centre aligned. The author's name must be a comment. This is the stylesheet: ``` <!-- Tariq Aziz --> h1, h2 { font-family: Gill Sans, Arial, "sans-serif"; font-size: 24px; color: 0033CC; text-align: centre; } ``` Identify six errors and write the correction for each.6 marks
  30. Mina builds a web page for a sports club on her own computer. The head section contains these two lines, in this order: ``` <link rel="stylesheet" href="club.css"> <link rel="stylesheet" href="C:\Users\Mina\site\match.css"> ``` `club.css` contains `h2 { color: #000099; }`. `match.css` contains `h2 { color: #006600; }` and `.result { color: #990000; }`. The body of the page contains: ``` <h2>Fixtures</h2> <h2 class="result">Scores</h2> <h2 style="color:#333333">Contact</h2> ``` State the colour code of each heading on Mina's computer and give a reason for each. The page and both stylesheets are then uploaded to one folder on a web server. State the colour code of each heading now, explain the change, and write the corrected line of HTML.7 marks

Go deeper

Practise and revise with member-only material for this chapter.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters