A-level Computer Science revision · Exchanging data

HTML, CSS and JavaScript

The idea

HTML structures web content with tags such as <h1>, <p>, <a>, <img>, <div> and <form>. CSS styles it using selectors, classes (.name) and identifiers (#name). JavaScript adds interactivity in the browser, such as validating forms before they are sent.

  1. HTML: structure. CSS: presentation. JavaScript: behaviour.
  2. CSS class selector: .warning { color: red; }
  3. Client-side JavaScript can validate input but the server must still check it.

Watch out Client-side validation can be bypassed, so the server must validate too.

See it worked

Worked example

Write CSS to make all elements with class 'note' blue.

  1. Select the class with a dot.
  2. .note { color: blue; }

Answer .note { color: blue; }

Your turn

Question 11 mark

Which HTML tag creates a hyperlink?

Choose one
Question 21 mark

Which CSS selector targets an element with id 'main'?

Choose one
Question 32 marks

Give one reason for using JavaScript to validate a form before submission.

Write your answer, then see a model answer
  1. Name the benefit.
  2. Explain it.

Answer It gives instant feedback to the user and reduces load on the server by catching errors before data is sent.

A-level Computer Science Pro, OCR H446

A-level Computer Science Pro

£119 once

Price rises to £199 on 1 January. Save £80 by joining before then.

At least 12 months of access

By paying you agree to our Terms and get access straight away, which ends your 14-day cancellation right.

No VAT is charged.

Independent practice for OCR A-level Computer Science (H446), not endorsed by OCR.

Privacy · Terms