By the end of this chapter, you will be able to:
Mastering these skills will help you build reliable, safe, and user-friendly web applications that work well in real-world projects!
Web application development relies heavily on writing source code that integrates user interface design and backend functionality to deliver seamless experiences. In Kenya's growing digital economy, software developers must efficiently create interactive interfaces and manage code versions to maintain quality and collaboration, especially in multi-developer environments. This chapter focuses on the tools and practices essential for developing user interfaces and controlling code versions, foundational skills for professional software developers working in diverse sectors such as banking, education, and public service.
User interface (UI) development is a critical part of web application development, as it shapes how users interact with software. Kenyan software developers need to select appropriate front-end tools that align with project requirements, team skills, and scalability needs. Understanding the variety of UI development tools available empowers developers to build responsive, accessible, and visually appealing web applications that meet user expectations across devices.
Front-end development tools encompass frameworks, libraries, code editors, and build tools that facilitate the creation of the user interface. These tools enable developers to streamline coding, enhance productivity, and ensure cross-browser compatibility. In Kenya's software development landscape, where projects range from simple websites for local businesses to complex portals for county governments, selecting the right front-end tools is essential.
The core of every web front end is made of three languages that the browser understands directly: HTML for structure, CSS for presentation and JavaScript for behaviour. Frameworks, editors and build tools are all layered on top of these three, so they are studied first.
Hypertext Markup Language (HTML) is the standard language used to describe the structure and content of a web page. A browser reads an HTML file and turns it into headings, paragraphs, images, links, forms and tables on the screen. Example: a Kisumu hospital builds an appointment page in HTML so that patients see the hospital name, a short description of services and a booking form.
Every HTML5 document follows the same basic skeleton:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lakeview Hospital</title>
</head>
<body>
<h1>Book an Appointment</h1>
<p>Choose a department and a date.</p>
</body>
</html>
The parts of the skeleton each have a clear job:
HTML5 also provides semantic elements that describe the meaning of each part of a page. They improve accessibility and search engine ranking because software can tell what each block is for.
A tag is a keyword enclosed in angle brackets that tells the browser how to treat content. An element is the complete unit made of an opening tag, the content and a closing tag. An attribute is extra information placed inside the opening tag as a name and value pair. Example: a Naivasha flower farm uses an order form in which each input element carries attributes that say what type of data is expected.
<a href="catalogue.html" title="Flower catalogue">View catalogue</a>
In this example, a is the tag name, href and title are attributes, "View catalogue" is the content, and the whole line from the opening tag to the closing tag is the element.
Some elements have no content and no closing tag. These are called void elements, for example br, hr, img and input.
<img src="roses.jpg" alt="Red roses in a greenhouse" width="300">
<input type="number" name="stems" placeholder="Number of stems" required>
Commonly used tags include:
Commonly used attributes include:
Elements can be nested inside one another, but they must be closed in the reverse order in which they were opened. For example, <p><strong>Sale</strong></p> is correct and <p><strong>Sale</p></strong> is not.
Cascading Style Sheets (CSS) is the language that controls how HTML elements look: colours, fonts, spacing, layout and responsiveness. Separating presentation from structure means one change in a style rule can update the look of an entire website. Example: a Mombasa hotel changes its brand colour once in CSS and every page of its booking website updates at the same time.
A CSS rule has a selector, which says which elements to style, and a declaration block with one or more property and value pairs:
h1 {
color: #0b5394;
font-size: 28px;
text-align: center;
}
The word cascading describes how the browser decides between conflicting rules. When several rules target the same element, the browser considers the importance of the rule (a declaration marked !important beats a normal one), how specific the selector is, and the order in which the rules appear. When importance is equal, a more specific selector wins over a less specific one, and when specificity is also equal the later rule wins. Styles written in an element's style attribute (inline CSS) rank above rules in style sheets of normal importance.
Common selector types are:
p..room-card.#main-menu.h1, h2, h3.nav a.a:hover for a link under the mouse pointer.Every element is treated by CSS as a rectangular box made of content, padding, border and margin. Padding is the space between content and border, and margin is the space outside the border. Understanding the box model is the basis of controlling layout.
CSS can be applied to a page in three ways: embedded, inline and external. Each is covered in the next three sections.
Embedded CSS, also called internal CSS, is written inside a style element placed in the head of one HTML document. The rules apply only to that page. Example: a SACCO publishes a single-page notice about its annual general meeting and embeds a few rules in the page so that the notice is one self-contained file.
<head>
<title>AGM Notice</title>
<style>
body { font-family: Arial, sans-serif; background-color: #f4f4f4; }
h1 { color: #1b5e20; }
.notice { border: 1px solid #1b5e20; padding: 12px; }
</style>
</head>
<body>
<h1>Annual General Meeting</h1>
<p class="notice">All members are invited to attend.</p>
</body>
The first three points below are situations where embedded CSS suits, and the last two are its limits:
Inline CSS is written directly in the style attribute of an individual HTML element. It affects only that element and has higher priority than rules in embedded or external style sheets (unless one of those rules is marked !important). Example: a county revenue office wants one warning message on its payments page to appear in red without changing any other text.
<p style="color: red; font-weight: bold;">Payments close at 4:00 pm today.</p>
Points to remember about inline CSS:
External CSS is kept in a separate file with the extension .css and is linked to each HTML page using a link element in the head. It is the preferred method for real projects because one file controls the look of the whole website. Example: a technical training institute with fifty pages links all of them to one style.css so that a change of logo colour is made in one place.
<head>
<link rel="stylesheet" href="css/style.css">
</head>
The advantages of external CSS are consistency, easier maintenance, smaller HTML files and browser caching, which speeds up later page loads, an important point where mobile data is costly.
Steps to create and link an external style sheet:
body { margin: 0; font-family: Arial, sans-serif; }.<link rel="stylesheet" href="css/style.css">. The href must match the file's path relative to the page.JavaScript is the programming language of the web. It runs in the browser and makes pages interactive by responding to clicks, checking form entries and changing content without reloading the page. Example: a Nakuru pharmacy's website uses JavaScript to show a greeting that depends on the time of day.
JavaScript can be added to a page in two ways: inside a script element, or in an external file linked with the src attribute. External files are preferred for the same reasons as for CSS.
<script src="js/app.js" defer></script>
let hour = new Date().getHours();
let greeting;
if (hour < 12) {
greeting = "Good morning";
} else if (hour < 18) {
greeting = "Good afternoon";
} else {
greeting = "Good evening";
}
console.log(greeting + ", welcome to our pharmacy.");
The basic building blocks of the language are:
let for values that change and const for values that must not be reassigned. The older var is best avoided.function add(a, b) { return a + b; }.if, else if, else and switch statements that choose which code to run depending on a condition.for, while and for...of repeat code, for example to display every item in a list.// single line or /* multiple lines */.console.log() prints values in the browser console, which developers use for testing and debugging.JavaScript is case sensitive, so total and Total are two different names. Statements normally end with a semicolon.
Every value in JavaScript has a data type that decides what can be done with it. JavaScript is dynamically typed, which means a variable can hold different types at different times. Example: a hardware shop's online quotation page stores the item name as a string, the quantity as a number and whether the item is in stock as a boolean.
Primitive data types are:
"Cement".50 or 2500.75.true or false, used in decisions.typeof null returns "object", even though null is a primitive.9007199254740993n.Non-primitive types include objects, arrays (ordered lists such as ["tiles", "paint"]) and functions. The typeof operator shows the type of a value, for example typeof 25 gives "number".
Operations are carried out with operators:
+, -, *, /, % (remainder) and ** (power).=, +=, -= and so on, for example total += 100 adds 100 to total.>, <, >=, <=, == and ===. Strict equality === compares both value and type, so 5 === "5" is false while 5 == "5" is true. Use === to avoid surprises.&& (and), || (or) and ! (not) combine conditions.+ operator joins strings, and template literals using backticks insert values, for example `Total: Ksh ${total}`.Adding a number to a string produces a string: "5" + 3 gives "53". Functions such as Number(), parseInt(), parseFloat() and String() convert between types deliberately. Input read from a form field is always a string, so it must be converted before calculation.
Example calculation: VAT at 16% on 5 bags of cement at Ksh 800 each.
Formula: VAT = price × quantity × 0.16
Substitution: VAT = 800 × 5 × 0.16
Working: 800 × 5 = 4,000; 4,000 × 0.16 = 640
Result: VAT = Ksh 640
const price = 800;
const quantity = 5;
const vat = price * quantity * 0.16;
console.log(`VAT: Ksh ${vat}`); // VAT: Ksh 640
The Document Object Model (DOM) is a representation of an HTML page as a tree of objects that JavaScript can read and change. The browser builds this tree when it loads the page, with the document object at the top, then the html element, then head and body, and so on down to each text node. Example: an Eldoret dairy cooperative's page uses the DOM to add each new milk delivery to a table without reloading.
Each tag becomes an element node, each piece of text becomes a text node and each attribute becomes an attribute node. Changing the tree changes what the user sees immediately.
Selecting elements:
".notice" or "#total".Changing elements:
element.style.color = "green".element.classList.add("active").Responding to events uses addEventListener:
const button = document.querySelector("#add");
const list = document.querySelector("#deliveries");
button.addEventListener("click", function () {
const item = document.createElement("li");
item.textContent = "Delivery recorded: 120 litres";
list.appendChild(item);
});
Scripts that use the DOM must run after the page elements exist. Placing the script at the end of the body, or using the defer attribute, makes sure the elements are available.
JavaScript libraries and frameworks provide ready-made code so that developers do not have to write everything from scratch. They shorten development time, reduce errors and give teams a shared structure. Example: a courier company's tracking page uses jQuery to show and hide parcel details when a customer clicks a row, with only a few lines of code.
jQuery is added to a page by linking its script file before your own script. The file can be loaded from a content delivery network (CDN) or downloaded and stored in the project:
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="js/app.js"></script>
Its basic syntax is:
$(selector).action();
The dollar sign $ calls jQuery, the selector uses the same notation as CSS to find elements, and the action is a method applied to those elements. To make sure the page is ready before the code runs, the code is wrapped in a ready function:
$(document).ready(function () {
$("#details").hide();
$("p.note").css("color", "blue");
});
Frequently used jQuery methods:
Methods can be chained, for example $("#box").addClass("open").fadeIn();.
An event is something that happens on the page, such as a click or a key press. jQuery attaches a function, called an event handler, to run when the event occurs:
$(document).ready(function () {
$(".parcel-row").click(function () {
$(this).next(".parcel-details").slideToggle();
});
$("#search").on("keyup", function () {
console.log($(this).val());
});
});
In the handler, $(this) refers to the element that triggered the event. Common events include:
The on() method is the general way to attach one or more events, and off() removes them. Modern frameworks such as React, Angular and Vue handle events in their own ways, but the idea of a handler responding to an event is the same.
A code editor is a program for writing source code with features such as syntax colouring and auto-completion. An IDE adds integrated debugging, project management and testing. The right choice depends on the size of the project, the budget and the computer's capacity. Example: the IT officer of a Kericho tea estate with an older office computer chooses a very light editor for editing the estate's notice-board pages, while a software firm building a large portal chooses a full-featured IDE.
| Name | Specification | Use |
|---|---|---|
| Visual Studio Code (VS Code) | Free, extensible editor with powerful debugging and Git integration | Widely used for HTML, CSS and JavaScript work |
| Sublime Text | Fast, lightweight editor known for simplicity | Quick edits and prototyping |
| WebStorm | Commercial IDE with advanced JavaScript support | Professional development of complex web applications |
| Atom | Open-source editor, discontinued by GitHub in 2022 | Historically used for general web editing; new projects should choose VS Code or a similar editor |
| Notepad++ | Free, very light text editor for Windows | Basic HTML and CSS editing on low-specification computers |
Build and automation tools prepare front-end code for production by combining, compressing and transforming files. They reduce page size and loading time, which matters for users on slow or costly mobile data. Example: a Thika school builds a student portal with many JavaScript files and images, and uses Vite to bundle and minify them so that the portal loads faster on learners' phones.
| Name | Specification | Use |
|---|---|---|
| Webpack | Module bundler that compiles JavaScript files and assets | Managing dependencies in large projects |
| Parcel | Zero-configuration bundler | Quick set-up for small projects |
| Gulp | Task runner using JavaScript pipelines | Automates repetitive tasks such as minification and compilation |
| Vite | Fast development server and bundler | Quick start-up and rebuilds for modern framework projects |
| Rollup | Module bundler focused on JavaScript libraries | Producing small bundled files from many modules |
Beyond editors and bundlers, front-end projects rely on supporting tools that keep code consistent, maintainable and tested. Each solves a problem that appears as a project and its team grow. Example: the web team of a bank uses Sass and Jest so that its internet banking pages stay easy to update and reliable after every change.
A CSS framework is a ready-made set of style rules and layout tools that saves developers from writing every rule themselves. Most include a responsive grid and styled components such as buttons, forms and navigation bars. Example: a Nairobi construction contractor with a small web team uses a CSS framework to build a project showcase site that works on phones and desktops in a few days.
Create a free account to open more of this chapter.
Free: practical guides, quick cards, workplace scenarios and more.
Create a free accountThis chapter explored the essential tools and techniques for writing web application source code, beginning with the creation of user interfaces using front-end development tools such as HTML, CSS in its various forms, the Document Object Model, and JavaScript frameworks like jQuery. It highlighted the importance of version control in managing changes to source code efficiently. The development of functionality and interactivity was examined alongside the methodology for implementing responsive design, emphasizing the adaptation to different screen resolutions. The chapter then delved deeper into front-end development, reviewing the basics of HTML, CSS, and JavaScript, including frameworks that enhance coding efficiency. Application Programming Interfaces were introduced with a focus on integration and testing to ensure seamless communication between software components. Server-side coding tools, particularly PHP, were covered as part of back-end development, which also included an overview of back-end frameworks. The implementation of back-end databases was discussed through steps for creation, connection, and manipulation via web interfaces, followed by insights into creating back-end APIs. Finally, the chapter addressed workplace safety and health practices relevant to web development environments, emphasizing compliance with OSHA regulations, and concluded with proper e-waste storage, disposal, and management practices to promote environmental responsibility.
At the start of this chapter we promised you would be able to:
Tick each one you can genuinely do.
So, are you there yet?
You're competent when you can confidently do 50% or more of what this chapter promised.
Sign in to record how you're doing.