Published by Patrick Mutisya · 14 days ago
Know and understand that the presentation layer is used to display and format elements within a web page.
The presentation layer is the part of a web page that determines how content looks to the user. It is primarily controlled by:
While HTML is a markup language, many tags have a direct impact on presentation. The table below summarises the most common presentation‑related tags.
| Tag | Purpose | Typical Use |
|---|---|---|
| <h1>–<h6> | Headings | Define hierarchical titles; default font size decreases from h1 to h6. |
| <p> | Paragraph | Blocks of text; browsers add vertical spacing before and after. |
| <div> | Division | Generic container used for grouping and applying CSS styles. |
| <span> | Inline container | Used to style a portion of text without breaking the flow. |
| <ul> / <ol> / <li> | Lists | Unordered (bulleted) or ordered (numbered) lists; list items are styled by default. |
| <table> / <tr> / <td> / <th> | Tabular data | Displays data in rows and columns; borders, spacing and alignment are controlled with CSS. |
| <a> | Hyperlink | Clickable links; default colour and underline can be changed via CSS. |
CSS provides the rules that tell the browser how to render each HTML element. The main concepts include:
p { … }).color, font-size, margin).color: #336699;).Every element is represented as a rectangular box. Understanding the box model is essential for controlling layout.
\$\text{Total width} = \text{content width} + 2(\text{padding}) + 2(\text{border}) + 2(\text{margin})\$
Similarly for height:
\$\text{Total height} = \text{content height} + 2(\text{padding}) + 2(\text{border}) + 2(\text{margin})\$
Manipulating these four areas allows precise placement of elements on the page.
Below is a minimal HTML snippet with embedded CSS that demonstrates how the presentation layer works.
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 20px;
}
h1 {
color: #2A5D9F;
margin-bottom: 10px;
}
.intro {
background-color: #F0F8FF;
padding: 15px;
border: 1px solid #B0C4DE;
}
p {
margin-top: 0;
}
</style>
</head>
<body>
<h1>The Presentation Layer</h1>
<div class="intro">
<p>This paragraph is inside a styled <code>div</code> that demonstrates background colour, padding and border.</p>
</div>
</body>
</html>
vertical-align or wrap images in a figure element with CSS.font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;).width plus padding and border does not exceed the parent’s width, or use box-sizing: border-box;.When answering exam questions on the presentation layer, make sure you have covered: