ITPEC IP October 2019 Question 8

A markup language specifies the character color according to the “Syntax and meaning of the markup language definition section” below. When an element (parent) contains another element (child), the child inherits the parent’s specifications, but priority is given to the child-specific specifications if the child and the parent have different values specified for the same attribute. When the text in the “Example” below is displayed according to this rule, which of the following is the appropriate display attribute for the underlined character string? Here, “<strong>character string</strong>” specifies the character string to be emphasized, for example by using bold font.

[Syntax and meaning of the markup language definition section](1)Syntax of the definition section . name{color specification}(2)Meaning Assigns a color attribute to “name” to display the character string (element) between <name> and </name> in the specified color.
[Example] Definition:. color1{blue} . color2{red} Body text:<strong>The role of the system administrator is <color1>to promote the use of computers and other information technology to end-user departments. <color2>Increased use of information technology improves the work efficiency of each user,</color2> and can also lead to operational improvements across the entire organization.</color1></strong>

Explanation

Red characters, emphasized — the underlined text takes red from its own color2 element and keeps the emphasis of the enclosing strong element.

The underlined string sits inside three nested elements: strong (outermost), then color1, then color2. Take each attribute separately:

  • •Colour: color1 specifies blue, and its child color2 specifies red for the same attribute, so the child's own value has priority: red
  • •Emphasis: only strong specifies it, and no inner element specifies anything different, so it is inherited down to the underlined text: emphasized

Answer (b)

Why not others:

  • •(a) Blue characters, emphasized — takes the colour from the parent color1, but the child color2 specifies its own colour, which has priority
  • •(c) Blue characters, not emphasized — wrong on both counts: the colour comes from color2, and the emphasis of strong is inherited
  • •(d) Red characters, not emphasized — right colour, but color2 specifies only colour; it does not cancel the emphasis inherited from strong

Key rule: Inheritance works attribute by attribute: a child overrides only the attributes it specifies itself and inherits all the others, as styles cascade through nested HTML elements in CSS.

Algorithm and Programming · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official IP past-paper collection or Report an issue.