In this lesson
The Big Idea
When you open a web page, you are usually looking at three technologies working together. HTML builds the page's structure (headings, paragraphs, images, links), CSS decides how it looks (colours, layout, sizes, fonts), and JavaScript adds behaviour and interactivity (a button that reacts when you press it, or one part of the screen that updates on its own). These are the frontend technologies whose role you met in Lesson 3-1. Modern frontend work goes further: pages that carry clear meaning thanks to semantic HTML, that fit every screen thanks to responsive design, and that are quicker to build thanks to frameworks and libraries.
Three Technologies, Three Roles: HTML, CSS and JavaScript
In many web pages these three technologies play different roles. To remember them, link each one to a single question:
| Technology | The question it answers | What it does | Analogy | |---|---|---|---| | HTML | What is on the page and how is it organised? | Defines the page's structure: headings, paragraphs, images, links | The building's frame | | CSS | How does that content look? | Defines the page's appearance: colours, layout, size, fonts | Interior and exterior decoration | | JavaScript | What happens when the user interacts? | Adds behaviour and interactivity: reacting to button presses, updating just part of the screen | Electricity and plumbing |
HTML: structure
HTML tells the browser "this is a heading, this is a paragraph, this is an image, this is a link". It does not care what colour the heading is or how big the font is; it cares about what each part is and where it sits. Here is a tiny page written in HTML alone:
<h1>My Favourite Books</h1>
<p>These are the books I enjoyed reading this year.</p>
<img src="the-days.jpg" alt="Cover of The Days by Taha Hussein">
<a href="library.html">Visit the school library</a>Each line is an element: h1 is a main heading, p a paragraph, img an image and a a link that takes you to another page. Open this page in a browser and it really works, but it shows plain text and default colours with no styling at all.
CSS: appearance
CSS takes that structure and gives it a look: the heading colour, the font size, the spacing, and how the parts are arranged on the screen (the layout). This small example makes every main heading dark blue and larger:
h1 {
color: darkblue;
font-size: 32px;
}Notice that CSS added no new content. The heading already exists in the HTML; CSS only changed how it looks. So if you want to change the background colour or the font across a whole site, that is a job for CSS.
JavaScript: behaviour
JavaScript makes the page interact with the user. Examples from pages you know:
- A "Like" button you press and the counter jumps from 12 to 13 straight away.
- A search box where the book list filters as you type.
- One part of the screen updating by itself (such as the number of people registered for an event) without reloading the whole page.
The key word is when: "when the user clicks", "when they type", "when the data changes". Anything that starts with "when" is usually JavaScript's work.
Does every page need all three?
No. The Arabic edition stresses that a page does not have to use all three. A simple page, such as a short instructions page, can be HTML only and still work in the browser. You add CSS when you want a better look and JavaScript when you need interaction, depending on what the page has to do. HTML is the foundation, though: styling or interaction means little without organised content first.
Semantic HTML: Elements That Explain Their Job
What is semantic HTML?
Semantic HTML means using elements whose name itself says what the part of the page is for, instead of building everything from plain boxes that say nothing about their content. The best-known ones:
| Element | Its job | Usual position |
|---|---|---|
| header | The page header: site name, logo or overall title | Top of the page |
| nav | The navigation area: links to the site's sections | Usually under or beside the header |
| main | The page's main content | The middle |
| footer | The page footer: contact details, copyright | Bottom of the page |
Here is the outline of a school library page written with semantic elements:
<header>
<h1>School Library</h1>
</header>
<nav>
<a href="index.html">Home</a>
<a href="books.html">Books</a>
</nav>
<main>
<h2>New Arrivals</h2>
<p>A new set of novels arrived this week.</p>
</main>
<footer>
<p>Contact: the librarian, first floor</p>
</footer>Read the code as if you could not see it in a browser: you can still tell at once where the header is, where the navigation links are, where the important content is and where the footer is. That is exactly what programs that read the page benefit from.
Two benefits of semantic HTML
① Accessibility. Accessibility means designing content and interfaces so that people with different abilities and needs can use them, including people with disabilities. A blind user, for example, uses a screen reader, a program that reads the page aloud. When a page uses nav and main, the screen reader can announce "navigation here" and jump straight to the main content instead of reading the whole page line by line. But note: semantic HTML helps accessibility; it is not enough on its own. Other practices are needed too, such as giving images a text description (like the alt in the first example).
② Search engines understanding the content. SEO (Search Engine Optimization) is a set of practices that make a page easier to index and to show up in search results. Semantic HTML may help search engines understand the structure of the content better, because they can tell where the main content and navigation are. But it does not guarantee a higher ranking; ranking depends on many other factors.
Responsive Design: One Page for Every Screen
What is responsive design?
You open the same site on the computer lab PC, on a tablet and on your phone. If the layout stayed exactly the same on the small screen, you would have to zoom and scroll left and right just to read one line. That is where responsive design comes in: a design concept in which the layout adjusts automatically to different screen sizes, such as computers, smartphones and tablets.
The key point is that the content stays the same; what changes is how it is arranged on the screen: three columns side by side on a computer, two on a tablet, one stacked column on a phone. This way the page adapts to the screen size and becomes easier to use.
The mobile-first approach
Many people browse the web on their phones. So developers think about small screens from the very start of the design, not as an add-on at the end. This is sometimes called the mobile-first approach: you design the page to work well on a phone first, then expand it for larger screens.
Frameworks and Libraries: Don't Start from Zero
What is a framework?
Nearly every site needs buttons, navigation menus, sign-up forms and product cards. If every developer wrote these from scratch in every project, a lot of time would go on repeated work. That is why we have the framework: a structure that provides commonly used functions and components in advance, to make web application development more efficient. With a framework, developers do not need to write all the code from scratch, so they can focus on what makes their app different.
Close to a framework is a library: a ready-made set of tools you call on for a particular job. Both help you build the interface from reusable components: design a "book card" once, then use it for a hundred books.
Popular libraries and frameworks
| Name | What is it? | What stands out | |---|---|---| | React | A JavaScript library | Builds user interfaces from reusable components and updates them when the data changes | | Vue | A framework | Simple structure; lets you build an app gradually, starting from small features | | Next.js | A framework built on React | For building web apps; provides routing between pages and different ways to render pages and to work on the server and the client |
Notice the relationship: React is a library for building interfaces, and Next.js is a framework built on top of it that adds what a complete web app needs. And remember from Lesson 3-2 that the server and the client are the two sides of the conversation; Next.js lets some of the work happen on one side and some on the other.
Try It Yourself
Common Mistakes
"Every web page must use HTML, CSS and JavaScript together"
The three play different roles, but they do not all have to appear on every page. A simple page can be HTML only and work fine.
A page uses HTML alone, or HTML with CSS and JavaScript, depending on what it needs to do.
"CSS is what makes a button react when you press it"
CSS decides how the button looks: its colour, size and shape. What happens when it is pressed, such as raising a counter or updating part of the screen, is behaviour.
Appearance belongs to CSS; behaviour and interactivity belong to JavaScript.
"Semantic HTML guarantees my site comes first in search results"
Semantic HTML may help search engines understand the content structure, but ranking depends on many factors, and nothing in the lesson says it guarantees a higher position.
Its benefits: it helps screen readers understand and navigate the structure, and it may help search engines understand the page, with no ranking guarantee.
"Responsive design means building a separate site for each device"
It is the opposite: one page whose layout changes automatically with the screen size.
Responsive design: one content, a layout that adjusts automatically to fit computer, tablet and phone.
"Using a framework means the developer writes no code"
A framework provides common functions and components ready-made, so the developer does not start from scratch, but they still write what is specific to their app.
A framework makes development more efficient by supplying the repeated parts.
Key Points
- HTML defines the page's structure (headings, paragraphs, images, links), like a building's frame.
- CSS defines the page's appearance (colours, layout, size, fonts), like the decoration.
- JavaScript adds behaviour and interactivity, such as reacting to button presses and updating only part of the screen, like electricity and plumbing.
- A page can use HTML alone, or add CSS and JavaScript as needed.
- Semantic HTML uses elements that state a part's job (
header,nav,main,footer); it helps screen readers and may help search engines understand the page, with no guarantee of a higher ranking. - Responsive design adjusts the layout automatically to the screen size; mobile-first considers small screens from the start.
- A framework provides ready-made functions and components, making development more efficient: React is a JavaScript library for interfaces, Vue a simple framework you can adopt gradually, Next.js a framework built on React.
FAQ
How do I quickly tell an HTML task from a CSS or JavaScript task in a matching question?
Ask: is the task about what is on the page, such as a heading, image or link? That is HTML. Is it about how it looks, such as colour, size or arrangement? That is CSS. Does it happen when the user clicks or types, or when data changes? That is JavaScript.
Is React a framework or a library?
According to the Arabic edition, which this site follows, React is a JavaScript library for building user interfaces from reusable components, and Next.js is a framework built on React. The English edition puts React in a table of frameworks, so answer according to the book you study from.
Does semantic HTML make my site faster or put it first on Google?
Not necessarily either. The book gives two benefits: it helps screen readers understand and navigate the page, and it may help search engines understand the content. It does not guarantee a higher ranking or a faster page.
Why do developers start designing with the phone?
Because many people browse the web on their phones, developers consider small screens from the start of the design and then expand the page for bigger screens. This is sometimes called the mobile-first approach.