Web Development Foundations: HTML, CSS, Java, and PHP
sewa3131 and StudyBoosterAI
Web Development Foundations: HTML, CSS, Java, and PHP
Imagine Sewale Animen creating a small website for KUE students in Addis Ababa. The website helps learners find course notes, submit questions, and read study tips. Each technology contributes a different part of the solution.
HTML creates the page structure. CSS controls its appearance and layout. PHP processes requests on the server. Java is a general-purpose programming language used for broader software development. JavaScript, not Java, is the language commonly executed in web browsers.
Understanding these technologies helps you see how a web application works from beginning to end. A student opens a page, the browser reads HTML and CSS, JavaScript may add interaction, and PHP can communicate with a server and database. This foundation supports later study of databases, software engineering, networking, and cybersecurity.
By the end, you should be able to:
1. Describe the role of HTML, CSS, Java, JavaScript, and PHP.
2. Create a semantic HTML page with a form.
3. Apply responsive CSS.
4. Explain the difference between Java and JavaScript.
5. Describe how PHP handles submitted data.
6. Identify basic accessibility, security, and debugging practices.
HTML is the skeleton: it gives the page structure.
CSS is the clothing: it gives color, spacing, typography, and layout.
PHP is the kitchen and server: it receives requests, processes information, and prepares a response.
Java is a general-purpose toolkit: it can be used for Android applications, enterprise systems, desktop software, and many other programs.
JavaScript is the browser’s activity coordinator: it can respond to clicks, validate input, and update the page without a full reload.
Step 1: Build the HTML structure
A course-notes portal might begin with this form:
<form method="post" action="save.php">
<label for="name">Your name</label>
<input id="name" name="name" type="text" required>
<label for="course">Course</label>
<input id="course" name="course" type="text" required>
<label for="question">Question</label>
<textarea id="question" name="question" required></textarea>
<button type="submit">Send question</button>
</form>
The label elements improve accessibility because screen readers can identify each input. The name attributes are important because PHP uses them to find submitted values. The required attribute provides basic browser validation.
Use meaningful structural elements such as header, nav, main, section, and footer. This is called semantic HTML. It makes the page easier for users, search engines, and assistive technologies to understand.
Step 2: Add responsive CSS
CSS can make the portal readable on a phone, tablet, or computer.
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
background: #f4f6f8;
color: #222;
}
main {
max-width: 700px;
margin: auto;
padding: 1rem;
}
input, textarea, button {
width: 100%;
box-sizing: border-box;
margin: 0.4rem 0 1rem;
padding: 0.7rem;
}
button {
background: #1769aa;
color: white;
border: 0;
cursor: pointer;
}
@media (min-width: 700px) {
main {
padding: 2rem;
}
}
Responsive design means the layout adapts to different screen sizes. The media query applies extra styling when the screen is at least 700 pixels wide.
Step 3: Understand PHP server processing
When a learner submits the form, the browser sends a POST request to save.php. A simple PHP handler could be:
<?php
$name = trim($_POST['name'] ?? '');
$course = trim($_POST['course'] ?? '');
$question = trim($_POST['question'] ?? '');
if ($name === '' || $course === '' || $question === '') {
exit('Please complete all fields.');
}
$name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
$course = htmlspecialchars($course, ENT_QUOTES, 'UTF-8');
$question = htmlspecialchars($question, ENT_QUOTES, 'UTF-8');
echo "Thank you, $name. Your question about $course was received.";
?>
The null coalescing operator prevents errors when a field is missing. trim removes unnecessary spaces. htmlspecialchars helps prevent harmful HTML from being displayed. In a real system, the data should be stored using a database connection with prepared statements.
Java and JavaScript: do not confuse them
Java is commonly used to build large software systems, Android applications, and backend services. Java code must usually be compiled before execution.
JavaScript is commonly run by browsers. It can make a form interactive, change page content, and check input before submission.
Their names are similar, but they are different languages with different histories, syntax details, tools, and typical uses. A browser does not normally execute Java code as webpage scripting.
TechnologyMain roleWhere it runsExample
HTMLPage structure and meaningBrowserHeadings, forms, links
CSSPresentation and layoutBrowserColors, spacing, responsive design
JavaScriptBrowser interactionUsually browserClick events and dynamic updates
PHPServer-side processingWeb serverHandling forms and database requests
JavaGeneral-purpose software developmentJava Virtual Machine or other platformsEnterprise and Android software
Common mistakes and debugging
A missing closing HTML tag may distort the entire page. An incorrect CSS selector may make styling appear ineffective. A PHP form may fail if the input name does not match the key used in $_POST. Always inspect the browser console, check the Network panel, read server error messages, and test one small change at a time.
Security and accessibility basics
Validate data on both the browser and server. Escape output. Use HTTPS for real websites. Use prepared database statements. Do not place passwords or secret keys directly in public code. Provide labels, readable color contrast, keyboard access, and descriptive text for images. Never rely only on client-side validation.
Recall: What is HTML’s main role?
Answer: It structures and gives meaning to web content.
Application: Which technology would process the submitted course question?
Answer: PHP on the server.
Analysis: A button is attractive but unusable with a keyboard. What should you investigate?
Answer: Check keyboard focus, semantic button usage, visible focus styling, and accessibility testing.
The World Wide Web was designed to connect documents through hyperlinks, but modern web applications now combine structure, styling, browser behavior, server processing, databases, and security into one system.
Crib sheet and memory method
HTML equals skeleton: structure.
CSS equals clothing: appearance.
JavaScript equals browser behavior: interaction.
PHP equals kitchen/server: processing.
Java equals general-purpose toolkit: wider software development.
Remember the sequence “Structure, Style, Stimulate, Serve”:
Stimulate interaction with JavaScript.
Serve and process requests with PHP.
Java is separate: it is the general-purpose toolkit, not the usual browser scripting language.
Create the first page of the KUE course-notes portal. Add three semantic sections, the form above, responsive styling, and a PHP handler. Test it with normal input, missing input, and text containing quotation marks. Write a short reflection explaining which part acts as the skeleton, clothing, kitchen, and toolkit.