Know and understand the purpose of the behaviour layer and how it works together with the content (HTML) and presentation (CSS) layers to create a complete web page.
| Layer | Primary technology | What it does |
|---|---|---|
| Content | HTML | Defines the structure, meaning and basic elements of the page (headings, paragraphs, tables, forms, media, links, bookmarks, etc.). |
| Presentation | CSS | Controls visual appearance – colours, fonts, layout, spacing, responsive design. |
| Behaviour | JavaScript (or another client‑side scripting language) | Adds interactivity, reacts to user actions, and can change the page while it is displayed. |
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8"> <!-- character set – required -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- responsive – required -->
<meta name="description" content="Brief description of the page"> <!-- optional but useful -->
<title>My Web Page</title>
<link rel="stylesheet" href="styles.css"> <!-- external CSS – see §3 -->
</head>
<body>
…content goes here…
</body>
</html>
<h1>…</h1> to <h6><p>…</p><ol>, unordered <ul> with <li><a href="page2.html">Link text</a><a id="top"></a> <!-- target – can be linked to with #top --><a href="#top">Back to top</a>
<img src="photo.jpg" alt="Description"><table><thead>
<tr><th>Header 1</th><th>Header 2</th></tr>
</thead>
<tbody>
<tr><td>Data 1</td><td>Data 2</td></tr>
</tbody>
</table>
<audio controls src="song.mp3"></audio><video controls src="movie.mp4"></video><form action="process.php" method="post"><label for="name">Name:</label>
<input type="text" id="name" name="name">
<label>Gender:</label>
<input type="radio" name="gender" value="M">Male
<input type="radio" name="gender" value="F">Female
<label for="country">Country:</label>
<select id="country" name="country">
<option value="uk">UK</option>
<option value="us">USA</option>
</select>
<button type="submit">Submit</button>
</form>
<section>, <article>, <nav>, <header>, <footer>images/photo.jpg (from the current folder)/assets/images/photo.jpg<link rel="stylesheet" href="styles.css">selector {property: value;
property: value;
}
p { margin: 0; }.highlight { background: yellow; }#mainHeader { color: #003366; }margin, border, padding, width, heightblock, inline, inline‑block!important)./* styles.css */body {
font-family: Arial, sans-serif;
line-height: 1.5;
margin: 20px;
}
h1 {
color: #2a7ae2;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ccc;
padding: 8px;
text-align: left;
}
.highlight {
background-color: #ffeb3b;
}
element.addEventListener('click', functionName);document.getElementById(), document.querySelector(), document.getElementsByClassName()
element.textContent = 'plain text'; – inserts only text.element.innerHTML = '<strong>HTML</strong>'; – inserts HTML markup.event.preventDefault();setTimeout() (run once after a delay) and setInterval() (repeat at regular intervals).<button id="changeBtn">Change text</button><p id="demo">Original paragraph.</p>
<script>
document.getElementById('changeBtn').addEventListener('click', function () {
// change only the text – no HTML is added
document.getElementById('demo').textContent = 'Paragraph updated by JavaScript!';
});
</script>
<form id="myForm"><label for="email">Email:</label>
<input type="email" id="email" name="email">
<button type="submit">Send</button>
</form>
<script>
document.getElementById('myForm').addEventListener('submit', function (e) {
var email = document.getElementById('email').value.trim();
if (email === '') {
e.preventDefault(); // stop form submission
alert('Please enter an email address.');
}
});
</script>
innerHTML and textContent.event.preventDefault() when handling forms.alt text, relative/absolute paths.textContent vs innerHTML, preventDefault(), setTimeout/setInterval, simple validation.Stack diagram showing the three layers:
Arrows point from the JavaScript layer down to the DOM, illustrating how scripts read and modify HTML elements that are then rendered with CSS styling.