Web Technologies and HTML: Tags, CSS, DNS, HTTP and Status Codes
Every website you open is the result of a browser asking a web server for files and then displaying them, using HTML for structure, CSS for appearance and JavaScript for behaviour. Computer papers for IT, web and lecturer posts ask which tag does what, what a domain name is made of, how HTTPS differs from HTTP and what a status code such as 404 means. Because this text cannot show angle brackets, tags are named in words, for example the paragraph tag p or the anchor tag a.
Asked in: PPSC, FPSC, NTS, ETEA, KPPSC, SSC, IBPS and ICS/ECAT computer
Client, server and browser
The web follows the client-server model. A client is the program that asks for a resource, normally a web browser such as Chrome, Firefox, Edge or Safari. A server is a computer running web server software, such as Apache or Nginx, that stores websites and sends pages back when asked. The browser’s job is to request files, receive them and render them, turning HTML, CSS and images into the page you see.
A browser is not the same as a search engine. A search engine is a website, opened inside a browser, that indexes other pages and helps you find them. A website is a collection of related web pages under one domain, and its first page is called the home page.
A static web page is stored as a fixed file and looks the same for every visitor. A dynamic page is built by the server when requested, often using a server-side language such as PHP, Python or Java together with a database, so it can show content such as a logged-in user’s own results.
- Client (browser) sends a request → server sends a response
- Browser: renders pages; search engine: finds pages
- Web server software: e.g. Apache, Nginx
- Static page: fixed file; dynamic page: built by the server on request
URLs, domain names and DNS
A URL (uniform resource locator) gives the full address of a resource, such as https://www.example.edu.pk/admissions/fee.html. It contains the protocol (https), the host or domain name (www.example.edu.pk), and a path to the particular file or page.
A domain name is read from right to left. The last part is the top-level domain (TLD): generic TLDs include .com, .org, .net and .edu, while country-code TLDs include .pk for Pakistan and .in for India. In example.edu.pk the TLD is pk, edu is the second-level domain, and example is the name registered by the organisation. The www at the front is a host name within that domain.
Computers on the Internet find each other by IP address, not by name. The Domain Name System (DNS) works like a phone book: when you type a domain, the browser first asks a DNS resolver for the matching IP address, and only then connects to that server and sends its HTTP request. A DNS A record maps a name to an IPv4 address, and an AAAA record maps it to an IPv6 address.
- URL = protocol + domain name + path
- Domain read right to left: TLD is the last part (.pk, .in, .com)
- Steps: DNS lookup → connect to server → HTTP request → response → page rendered
- A record: name → IPv4; AAAA record: name → IPv6
HTTP, HTTPS, cookies and status codes
HTTP (HyperText Transfer Protocol) is the set of rules browsers and servers use to exchange web pages. HTTP is stateless: each request is handled on its own, and the server does not automatically remember earlier ones. Websites use cookies, small pieces of data stored by the browser and sent back with later requests, to remember things such as a login session or a chosen language.
HTTPS is HTTP sent through an encrypted TLS connection (older versions were called SSL). It keeps data such as passwords private in transit and uses a digital certificate to prove the server’s identity; browsers show a padlock for it. By default HTTP uses port 80 and HTTPS uses port 443.
The two most common request methods are GET, which asks for a resource and places any form data in the URL, and POST, which sends form data in the body of the request; POST is the right choice for passwords and large forms. Every response carries a three-digit status code. 2xx codes mean success, with 200 OK the usual one; 3xx mean redirection, such as 301 Moved Permanently; 4xx mean a client-side error, such as 403 Forbidden and 404 Not Found; 5xx mean a server-side error, such as 500 Internal Server Error and 503 Service Unavailable.
- HTTP: stateless, port 80; HTTPS: HTTP over TLS encryption, port 443
- Cookie: small data stored by the browser for a website
- GET: data in the URL; POST: data in the request body
- 200 OK; 301 Moved Permanently; 403 Forbidden; 404 Not Found
- 500 Internal Server Error; 503 Service Unavailable
- 2xx success, 3xx redirect, 4xx client error, 5xx server error
HTML structure and common tags
HTML (HyperText Markup Language) is a markup language, not a programming language: it describes the structure and meaning of content using tags written inside angle brackets. Most elements have an opening and a closing tag around their content; a few, such as the line break br and the image img, are empty elements with no closing tag. Tags are not case-sensitive, but lowercase is the convention.
Every page has the html element containing two parts. The head holds information about the page, including the title element, whose text appears on the browser tab and in search results, and links to style sheets. The body holds everything shown in the window.
Headings run from h1, the largest and most important, down to h6, the smallest. The paragraph tag p makes a paragraph, br forces a line break, and hr draws a horizontal line. The anchor tag a creates a hyperlink, with the destination given in its href attribute. The image tag img shows a picture, whose file is given in the src attribute and whose text description, read aloud by screen readers and shown if the image fails, goes in the alt attribute.
- html → head (title, links, meta) + body (visible content)
- h1 largest heading … h6 smallest
- a + href: hyperlink; img + src: image file; alt: alternative text
- p: paragraph; br: line break (empty element); hr: horizontal rule
Lists, tables and forms
An ordered list ol shows numbered items and an unordered list ul shows bulleted items; inside both, each item is an li (list item). A description list dl pairs terms with their descriptions.
A table is built with the table tag. Each row is a tr (table row); ordinary cells are td (table data) and heading cells are th (table header), which are bold and centred by default. The colspan and rowspan attributes let a cell stretch across several columns or rows.
The form tag collects input from users. Inside it, the input tag creates text boxes, password boxes, check boxes, radio buttons and submit buttons according to its type attribute; textarea gives a multi-line box and select gives a drop-down list. The form’s action attribute names where the data goes and its method attribute is GET or POST.
- ol: numbered list; ul: bulleted list; li: list item
- tr: row; td: data cell; th: header cell
- colspan/rowspan: merge cells across columns/rows
- form + input (type), textarea, select; method GET or POST
The roles of CSS and JavaScript
CSS (Cascading Style Sheets) controls presentation: colours, fonts, spacing, borders and page layout, including how the layout adapts to phones and large screens. Keeping style in CSS and content in HTML means one style sheet can restyle a whole website. CSS can be written inline in a style attribute, internally in a style element in the head, or externally in a separate .css file linked to many pages; when rules conflict, an inline style normally takes priority over the others, which is the cascade at work.
JavaScript is the programming language built into web browsers. It makes pages interactive: checking a form before it is sent, showing and hiding menus, or fetching new data without reloading the page. In short, HTML is the structure, CSS is the appearance and JavaScript is the behaviour.
Code that runs in the browser is client-side; code that runs on the web server, such as PHP, is server-side. The W3C (World Wide Web Consortium) develops many of the open standards the web relies on.
- HTML = structure; CSS = presentation; JavaScript = behaviour
- CSS types: inline, internal, external (.css file)
- Client-side: runs in the browser (JavaScript)
- Server-side: runs on the server (e.g. PHP)
Solved examples
- Identify the protocol, domain name, top-level domain and path in the URL https://www.example.edu.pk/admissions/fee.html.
- The part before the colon and two slashes is the protocol: https.
- The host is www.example.edu.pk; read from the right, its top-level domain is pk (Pakistan) and edu is the second-level domain.
- Everything after the domain is the path: /admissions/fee.html, the file being requested.
Answer: Protocol https; domain www.example.edu.pk; TLD pk; path /admissions/fee.html - Priya types a website address into her browser for the first time. Put these steps in order: the browser renders the page; DNS returns the IP address; the server sends back HTML; the browser sends an HTTP request; the browser asks DNS for the IP address.
- The browser cannot contact a server by name, so it first asks DNS for the IP address.
- DNS returns the IP address, and the browser connects to that server.
- The browser sends its HTTP (or HTTPS) request for the page.
- The server replies with the HTML, and the browser renders the page, requesting any CSS, scripts and images it mentions.
Answer: Ask DNS → IP returned → HTTP request → HTML response → page rendered - Bilal is told that his website returned 200 for the home page, 404 for an old link and 500 for the login page. What does each mean, and which one should he fix in his own server code?
- 200 OK: the home page request succeeded.
- 404 Not Found: the server is working, but the requested address does not exist, usually a broken or mistyped link.
- 500 Internal Server Error: the server itself failed while handling the login request, so the fault lies in the server-side code or configuration.
Answer: 200 success, 404 page not found, 500 server error; the 500 points to his server code - Which tags would Ayesha use to show a heading, a paragraph, a link to another site and a picture of her school, and which attributes do the link and picture need?
- A main heading uses h1, and the text paragraph uses p.
- The link uses the anchor tag a, with the destination URL in its href attribute.
- The picture uses the empty img tag, with the file in src and a short description in alt for screen readers and for when the image cannot load.
Answer: h1, p, a (href) and img (src and alt) - Ravi wants a timetable with a header row (Day, Subject) and two data rows. Which tags build it, and how many td cells will it have?
- The whole table goes inside the table tag, and each row is a tr, so there are 3 tr elements.
- The header row uses th for Day and Subject, giving 2 th cells.
- Each of the two data rows has 2 td cells, so 2 × 2 = 4 td cells.
Answer: table, tr, th and td; 3 rows, 2 th cells and 4 td cells - Neha’s login form sends the username and password using GET, and she notices them appearing in the address bar. The site also uses plain HTTP. What two changes should she make, and why?
- GET places form data in the URL, where it can be saved in browser history and server logs, so the form should use POST, which sends data in the request body.
- Plain HTTP sends everything unencrypted, so anyone on the network path could read it; the site should use HTTPS, which encrypts the connection with TLS.
- POST alone does not encrypt the data, so both changes are needed.
Answer: Use the POST method and serve the site over HTTPS
Exam shortcuts
- Remember the trio: HTML builds the structure, CSS styles it, JavaScript makes it act.
- For status codes look at the first digit: 2 success, 3 redirect, 4 your request is wrong, 5 the server failed.
- Read domain names from right to left; the TLD is always the last part.
- In tables, r is for row (tr), d is for data (td) and h is for header (th).
- o in ol stands for ordered (numbered); u in ul stands for unordered (bullets).
- href goes with links, src goes with images and scripts.
Common mistakes
- Calling HTML a programming language; it is a markup language.
- Confusing a web browser with a search engine.
- Thinking the link tag link creates a clickable hyperlink; it attaches resources such as style sheets, while the anchor tag a makes hyperlinks.
- Believing 404 means the server is down; the server answered, but the page was not found.
- Assuming POST alone makes data secure; only HTTPS encrypts it in transit.
Practice MCQs
- What does HTML stand for?
A) Home Tool Markup Language
B) High Transfer Machine Language
C) HyperText Markup Language
D) Hyperlink and Text Management Language
Answer: C) HyperText Markup Language — HTML is HyperText Markup Language: hypertext because pages link to each other, and markup because tags mark the structure of the content. The other expansions are invented. - Which tag creates a clickable hyperlink to another page?
A) The nav tag
B) The anchor tag a
C) The link tag link
D) The href tag
Answer: B) The anchor tag a — The anchor tag a, with the destination in its href attribute, makes a hyperlink. The link tag connects a page to resources such as a style sheet, href is an attribute rather than a tag, and nav only groups navigation content. - Which heading tag produces the largest heading by default?
A) header
B) h6
C) head
D) h1
Answer: D) h1 — Headings run from h1, the largest and most important, to h6, the smallest. The head tag holds page information that is not displayed, and header groups introductory content without setting a size. - In the image tag img, which attribute gives the location of the image file?
A) title
B) alt
C) href
D) src
Answer: D) src — The src (source) attribute names the image file to load. alt gives a text description, href is used by links, and title adds a tooltip. - Which technology mainly controls the colours, fonts and layout of a web page?
A) HTML
B) JavaScript
C) CSS
D) HTTP
Answer: C) CSS — CSS (Cascading Style Sheets) handles presentation. HTML gives structure, JavaScript adds behaviour, and HTTP is the protocol that transfers the files. - A browser receives the status code 404 for a requested page. What does it mean?
A) The requested page was not found on the server
B) The request succeeded normally
C) The server had an internal error
D) The page has moved permanently
Answer: A) The requested page was not found on the server — 404 Not Found is a client-error code: the server is running but has no resource at that address. Success is 200, an internal server failure is 500, and a permanent move is 301. - A site shows the status code 500 when Usman submits a form. Where does the problem lie?
A) In the web server or its code
B) In a redirect to another page
C) In Usman’s spelling of the address
D) Nowhere; 500 means success
Answer: A) In the web server or its code — Codes from 500 to 599 report server-side errors, and 500 means the server failed while processing the request. A mistyped address would give a 4xx code such as 404, success is 200, and redirects use 3xx codes. - Which tag creates a numbered list?
A) dl
B) ol
C) li
D) ul
Answer: B) ol — ol is the ordered list, which numbers its items. ul gives bullets, li marks each item inside a list, and dl is a description list of terms and definitions. - In an HTML table, which tag starts a new row?
A) th
B) tr
C) caption
D) td
Answer: B) tr — tr (table row) holds one row of cells. td is a data cell, th is a header cell, and caption gives the table a title. - What is the top-level domain in www.example.edu.pk?
A) example
B) edu
C) pk
D) www
Answer: C) pk — Domains are read from the right, and the last part, pk, is the country-code top-level domain for Pakistan. edu is the second-level domain, example is the registered name, and www is a host name. - What is the main advantage of HTTPS over HTTP?
A) It loads pages without any server
B) It does not need DNS
C) It encrypts the data exchanged using TLS
D) It stores pages permanently on the user’s disk
Answer: C) It encrypts the data exchanged using TLS — HTTPS runs HTTP through an encrypted TLS connection and verifies the server with a certificate, protecting data in transit. It still needs a server and DNS, and it has nothing to do with storing pages permanently. - Which language is built into web browsers and is mainly used to make web pages interactive?
A) SQL
B) CSS
C) PHP
D) JavaScript
Answer: D) JavaScript — JavaScript runs inside the browser to respond to clicks, check forms and update content. PHP runs on the server, SQL queries databases, and CSS only styles pages. - A website remembers that Sadia is logged in when she opens another page, even though HTTP is stateless. What small piece of data stored by her browser makes this possible?
A) A DNS record
B) A cookie
C) A domain name
D) A status code
Answer: B) A cookie — A cookie is a small item of data the browser stores and sends back with later requests, letting the server recognise the session. DNS records map names to addresses, status codes report the result of a request, and a domain name identifies the site. - Where does the text inside the title element normally appear?
A) On the browser tab
B) Inside the address bar instead of the URL
C) As the largest heading on the page
D) At the bottom of every page
Answer: A) On the browser tab — The title element sits in the head, and its text is shown on the browser tab and used in bookmarks and search results. It is not shown as a heading in the page body, as a footer, or in place of the URL. - Arjun types a website’s name into his browser for the first time. What must happen before the browser can send its HTTP request?
A) DNS must return the server’s IP address
B) The page must be rendered
C) The server must send a 200 status code
D) The CSS file must be downloaded
Answer: A) DNS must return the server’s IP address — The browser can only connect to a server by IP address, so the DNS lookup comes first. Rendering, the 200 response and downloading the CSS all happen after the request has been sent.
Questions
Is HTML a programming language?
No. HTML is a markup language that describes the structure of content. It has no variables, loops or decisions; JavaScript provides the programming on a web page.
What is the difference between the Internet and the web?
The Internet is the worldwide network of connected networks. The World Wide Web is one service that runs on it: linked pages transferred with HTTP. Email and file transfer also use the Internet without being the web.
Does HTTPS mean a website is trustworthy?
No. HTTPS only means the connection is encrypted and the certificate matches the domain. A fraudulent site can also use HTTPS, so the domain name itself still needs checking.
What is the difference between GET and POST?
GET requests a resource and puts any form data in the URL, so it can be bookmarked and is visible. POST sends data in the request body, which suits passwords and large forms, but it needs HTTPS for the data to be encrypted.