Web Technologies Explained: HTML, CSS, JavaScript and HTTP with Worked Examples

Connect HTML, CSS, JavaScript, DNS and HTTP by following one result page from its URL to its final DOM state after two button clicks.

KnowledgeGate Team

Exam prep & CS education

Updated 20 Nov 20266 min read
Web Technologies Explained: HTML, CSS, JavaScript and HTTP with Worked Examples

HTML, CSS, JavaScript, HTTP, DNS, browsers and servers are often memorised as separate definitions. That makes a question combining them much harder than it needs to be. The pieces make more sense when followed in sequence. A page can be understood as one connected sequence from a typed URL to two button clicks. The sequence shows each technology's role, the CSS calculation, and the JavaScript output.

Web technologies form one client-server system

The Internet is the network infrastructure and protocol stack that connects computers. The Web is a service built on that infrastructure using URLs, HTTP or HTTPS, browsers and web servers.

A client, usually a browser, requests a resource such as an HTML document. A server receives the request and returns a response containing that resource or an outcome explaining what happened. HTML provides document structure, CSS controls presentation, and JavaScript changes behaviour and state. DNS maps a host name to an address, while HTTP transfers representations of resources.

For a dynamic page, a backend may read or update a database before producing the response. In the normal three-tier model, the browser talks to the server-side application, not directly to the database. If you want a broader practical route through these layers, explore the Skills category.

A left-to-right map from browser to DNS to web server to the HTML, CSS and JavaScript response, with a backend database branch.

HTML builds the document and the DOM tree

An HTML element is a unit of document structure, commonly written with tags. Attributes add information to an element, such as an identifier or class. Nesting places one element inside another, while semantic elements describe the purpose of content instead of only its appearance.

Consider this source fragment:

html
<div id="card" class="panel">
  <p class="score">12</p>
  <button id="add">Add 5</button>
</div>

The browser parses it into a DOM tree. Its root here is div#card.panel, with two children: p.score, containing the text 12, and button#add, containing Add 5. The source is text sent to the browser; the DOM is the browser's in-memory tree built from it. JavaScript selects and changes DOM nodes, not an abstract screenshot. An id should identify one element, while a class can be reused. Practise these relationships in Complete HTML.

CSS chooses a winning rule and computes a box

CSS uses selectors to target elements and declarations to assign property values. The cascade resolves competing declarations by considering factors including origin, importance, specificity and source order. Some properties, such as color, can be inherited by descendants when they have no winning value of their own.

Suppose the page contains these rules:

css
p { color: black; }
.panel .score { color: blue; }
#card .score { color: orange; }

Their specificities are (0,0,1), (0,2,0) and (1,1,0) respectively. Compare the ID column first. The third selector has one ID, so #card .score wins and the score is orange. A later rule wins by source order only when origin, importance and specificity are otherwise equal.

Now give .panel a content width of 240px, left and right padding of 20px, and left and right borders of 2px. With box-sizing: content-box, its outer width is 240 + 20 + 20 + 2 + 2 = 284px. With border-box, the outer width stays 240px, while the content width becomes 240 - 40 - 4 = 196px.

JavaScript turns the static DOM into an interactive page

The initial HTML creates a static DOM state. JavaScript can listen for an event, select a DOM node and update one of its properties without loading a new document.

javascript
const score = document.querySelector('.score');
document.querySelector('#add').addEventListener('click', () => {
  score.textContent = Number(score.textContent) + 5;
});

The first selector stores the paragraph node in score. The second finds the button and attaches a click listener. Before any click, score.textContent is the string "12". On the first click, Number("12") + 5 evaluates to 17, which becomes the new text. On the second, Number("17") + 5 = 22. The final DOM text is "22", and the winning CSS rule still makes it orange.

The conversion matters. Without Number, JavaScript can concatenate a string and a number, producing "125" from "12" + 5 instead of the arithmetic result 17.

URLs, DNS, HTTP and HTTPS carry the page

Parse https://exam.example/result.html into scheme https, host exam.example and path /result.html. Both exam.example and 203.0.113.10 are documentation-only values here, not live services.

In this HTTP/1.1 teaching trace, DNS returns 203.0.113.10. The client opens a TCP connection, negotiates TLS and sends GET /result.html HTTP/1.1 with Host: exam.example. The server returns HTTP/1.1 200 OK with Content-Type: text/html. After parsing that HTML, the browser requests /styles.css and /app.js; both are assumed to return 200 OK in this example.

Each component has a distinct job. DNS finds an address. HTTP defines request and response messages. HTTPS protects HTTP in transit and authenticates the server. Status families communicate outcomes. The first digit groups responses broadly, while all three digits identify a specific status: 200 means success, 301 is redirection, 404 identifies a client-error outcome, and 500 identifies a server-error outcome.

Web page worked example: trace the result from URL to two clicks

The page request and interactions proceed in this order:

  1. Parse the URL into https, exam.example and /result.html.

  2. Resolve the host through DNS to 203.0.113.10.

  3. Establish the secure connection and send GET /result.html.

  4. Receive 200 OK, then parse the HTML into div#card.panel with score text 12 and the button.

  5. Fetch the CSS and JavaScript, each with an assumed 200 OK response.

  6. Compare CSS specificity. (1,1,0) beats (0,2,0) and (0,0,1), so orange wins.

  7. Calculate the content-box width again: 240 + 20 + 20 + 2 + 2 = 284px.

  8. Paint orange text 12 and attach the click listener.

  9. Click once: Number("12") + 5 = 17. Click again: Number("17") + 5 = 22.

Final result: visible score 22, score colour orange, panel outer width 284px, and last main-document status 200 OK.

The initial document and asset fetches require server round trips. The two clicks do not, because this handler only edits the local DOM and sends no network request.

A two-column trace of the result page: DNS and HTTP status steps on the left, CSS specificity, the 284px width and score 22 on the right.

Web technologies exam questions test distinctions and traces

Practise four exam-style question types:

  • Definition pairs: Internet or Web, static or dynamic, client or server.

  • Sequence: DNS before HTTP, parsing before rendering.

  • Calculation: CSS specificity, box width or JavaScript output.

  • Protocol choice: GET or POST, 404 or 500, HTTP or HTTPS.

Watch for these shortcuts:

Trap

Wrong shortcut

Correct test

HTML

It is a programming language

It structures and describes content

CSS specificity

The last rule always wins

Compare specificity before source order

JavaScript

A DOM change is saved

Persistence needs storage or a server request

HTTPS

Secure transport fixes faulty logic

It protects transport, not application correctness

404

Server-generated means server error

It belongs to the client-error family

For exam review, use Web Technologies for Teaching Exams: HTML and HTTP. Then test markup with HTML Interview Questions for Freshers.

Web technologies in the short version

The complete chain is URL to DNS to secure connection to HTTP response to HTML DOM to CSS layout and paint to JavaScript events. In the worked page, two clicks leave an orange score of 22 inside a panel whose outer width is 284px.

If you need a broad project path covering the front end and server-side work, continue with MERN Stack. If only document structure feels weak, the earlier Complete HTML route is sufficient. Trace this example once without notes, then vary one selector, one width or one click value and recompute the result.