Web Technology: HTML, CSS and JavaScript
Web Technology: HTML, CSS and JavaScript
The exam tests document structure, presentation rules, and client-side behaviour, including form validation.
HTML
- HTML describes structure with elements and attributes:
<html>,<head>,<body>, headings, lists, links, images, tables, forms. - Attributes use
name='value'; tags nest properly. - Forms collect input;
actionsends data to a server,methodis usuallyGETorPOST.
CSS
- CSS controls presentation. Three placements: inline (
styleattribute), internal (<style>), external (.csslinked with<link>). - Selectors: element,
.class,#id. Specificity order: inline > id > class > element. - Box model: content, padding, border, margin.
JavaScript
- Runs in the browser; adds interactivity and validation.
- Variables via
let/const; functions; DOM access withdocument.getElementById(). - Events such as
onclick,onsubmit,onchange;return falsefrom a handler can cancel submission.
Worked example
A form field id='age' is validated on submit: read let a = document.getElementById('age').value; then if (a === '' || isNaN(a)) { alert('Enter a number'); return false; }. Reasoning: value is a string; isNaN checks numeric validity; returning false stops the form from being sent, so invalid data never reaches the server.
Traps
- Using
=instead of===in conditions. - Assuming JavaScript runs on the server; it runs client-side here.
- Expecting CSS
idselectors to be written with.; ids use#. - Placing
<script>before the elements it accesses without handling load order. - Relying only on client-side validation; server-side validation is still required.