ExamBank Scot · Higher Computing Science question bank · All Higher Computing Science questions

Higher Computing Science 2022 Question 16

9 marks · CSS appearance and positioning

They are redesigning their home page and want to implement the spacings shown below. Welcome to ScotEco energy. We are a new online energy supplier available to all residential customers in Scotland. We aim to offer 100% customer service and 100% renewable energy. Using the partially completed code below, complete the CSS rules to implement the appropriate spacing as shown above. <style> main { background-color: darkgrey;} p { background-color: lightgrey; ; ;} </style> <main> <p>Welcome to ScotEco energy. We are a new online energy supplier available to all residential customers in Scotland</p> <p>We aim to offer 100% customer service and 100% renewable energy.</p> … A navigation bar will be included across the site. Complete the CSS rule that will change the colours to black and white if the cursor moves over a link. nav { height:40px; } nav ul li { float:left;width:100px;text-align:center; } nav ul li a { display:block;padding:10px; } nav ul li ___________________{ __________________________; ; } One of the web pages uses multiple div elements as shown below. <p>Tariff one</p> <p>Tariff two</p> <p>Tariff three</p> They are to be displayed as shown below. Tariff one Tariff two Tariff three The CSS rule below is added. p { display: inline ;} Explain why this CSS rule displays the contents of the elements side by side. When an image, ‘question.jpg’, on the web page is clicked, it should display the text: ‘For more help call us on 0800 300200’ The JavaScript code below does not correctly implement this feature. <script> function displayHelp(){ document.getElementById("display").style.display="block"; } </script> <p>For help please click on the icon below.</p> <img src="question.jpg" > <div id="help" style="display:none"> <p>For more help call us on 0800 300200</p> </div> … Re‑write the line of code which will use a JavaScript event to call the function displayHelp when the image ‘question.jpg’ is clicked. Explain why the text is still not displayed when the function displayHelp is called. All customers have electricity meters and some customers also have a gas meter. The HTML code below allows the user to enter their meter readings. … <form> … Electricity Meter Reading <br> <input type="number" name="electricity"> Gas Meter Reading <br> <input type="number" name="gas"> <input type="submit"> … </form> … Re‑write the line of HTML code to ensure that a reading has been entered for the electricity meter. An energy supplier’s website allows customers to log in and manage their account online.

Marking scheme

• margin-top: 30px • padding-top: 20px 1 mark for each bullet margin{30 0 0 0;} padding{20 0 0 0;} • a:hover selector • background-color is black, color is white 1 mark for each bullet nav ul li a:hover {background-color:black; color: white;} An element with an inline property only takes up the width that is needed. • onclick event • correct displayHelp function call 1 mark for each bullet <img src="question.jpg" onclick="displayHelp()"> Parameter ‘this’ may be included. Incorrect ID ‘display’ is used as a parameter in the function. OR Correct ID ‘help’ should be used as a parameter in the function. Add required to electricity input. <input type="number" name="electricity" required>

Previous question: Higher Computing Science 2022 Question 15

Next question: Higher Computing Science 2023 Question 1