CS420 – Web Development for Mobile Devices: Midterm Important Subjective (26 Solved Q&As)
Computer Science • Read every solved subjective question with its model answer directly on this page. Free, no login required.
All 664 Midterm Packs · CS420 Course Page · CS420 MCQ Pack (22 MCQs)
-
What is responsive web design? Why is it important for mobile devices?
Topic: Responsive Web Design — Concepts & Approaches • 3 marks marks
Responsive web design is the practice of building a website that works suitably on every device and every screen size, no matter how large or small, mobile or desktop. The same website automatically adjusts its layout, content and images according to the screen on which it is viewed. It is important for mobile devices because phones and tablets have small screens, different resolutions and mostly touch input. Without responsive design, a mobile user would face wasted space, tiny unreadable text and would be forced to zoom and scroll horizontally. A responsive site keeps the content readable and usable on the small screen without a separate website.
-
Differentiate between responsive, adaptive and fixed web design.
Topic: Responsive Web Design — Concepts & Approaches • 5 marks marks
Responsive web design: The layout is built on a fluid grid and uses media queries to control the design and its content as it scales up or down with the browser or device. One single flexible layout adjusts continuously to any screen width. Adaptive web design: The server or the browser detects the device and delivers one of several pre-designed fixed layouts (e.g. a separate layout for phone, tablet and desktop). The layout jumps between fixed sizes instead of flowing continuously. Fixed web design: The page has a fixed width (in pixels) that never changes. On a smaller screen it overflows and forces horizontal scrolling and zooming; on a larger screen it wastes space on the sides. In short, a responsive design flows, an adaptive design switches between ready-made layouts, and a fixed design does not change at all.
-
What is meant by the "mobile-first" design approach? State its advantages.
Topic: Responsive Web Design — Concepts & Approaches • 3 marks marks
Mobile-first design means starting the design with mobile devices — designing first for the smallest screen — and then progressively enhancing the design for tablets and desktops with larger screens. Advantages: (1) The most essential content and features are prioritized, because space on a mobile screen is limited. (2) The site stays fast and light, which suits mobile networks and processors. (3) It is easier to scale a simple mobile layout up to a big screen than to squeeze a complex desktop layout down to a phone.
-
Name and briefly explain the three main techniques used in responsive web design.
Topic: Responsive Web Design — Concepts & Approaches • 3 marks marks
The three main techniques of responsive web design are: 1. Fluid grid: The page layout is divided into columns and all measurements are given in relative units such as percentages instead of fixed pixels, so the layout stretches or shrinks with the screen. 2. Flexible images and media: Images and videos are made flexible (for example with max-width: 100%) so they scale within their containing element and never overflow the screen. 3. Media queries: CSS media queries check the device's features (such as width) and apply different styles for different screen sizes, controlling the design and its content as it scales.
-
Why must the content of a mobile site comply with the user's expectations? What happens if it does not?
Topic: Responsive Web Design — Concepts & Approaches • 3 marks marks
Mobile users visit a site with clear expectations: the important content should be easy to find, readable without zooming, quick to load and simple to use with touch on a small screen. A mobile site's content must comply with these expectations so that users can complete their tasks comfortably. If the content does not match the user's expectations — for example if key information is missing, hidden or hard to read on the phone — users become frustrated and leave the site. That is why services such as WordPress are configured to give a totally different, phone-suitable version of the site to phones instead of the desktop version.
-
What is the viewport? Why is setting the viewport the first thing needed to make a mobile-friendly page?
Topic: Viewport & Mobile-Friendly Pages • 3 marks marks
The viewport is the visible area of a web page on the device's screen — the portion of the page the user can see at one time. Mobile browsers normally render the page at a desktop-like width and then shrink it, which makes the text tiny. Setting the viewport is the first step in making a mobile-friendly page because it tells the mobile browser how wide the page should be and how it should be scaled. Only when the viewport is set correctly (to the device width) will the browser lay the page out for the actual phone screen, and techniques like media queries will work on the real screen width.
-
Write the viewport meta tag and explain its two commonly used settings.
Topic: Viewport & Mobile-Friendly Pages • 5 marks marks
The viewport meta tag is placed inside the <head> section of the HTML page: <meta name="viewport" content="width=device-width, initial-scale=1.0"> Its two commonly used settings are: 1. width=device-width: This sets the width of the page equal to the screen width of the device (in device-independent pixels). The page is laid out for the phone's own width instead of a default wide layout viewport. 2. initial-scale=1.0: This sets the initial zoom level when the page is first loaded by the browser. A value of 1.0 means the page opens at its natural size, with no zoom in or out. Together these settings stop the browser from shrinking the desktop layout and let the responsive design display correctly on the mobile screen.
-
What problem did Apple solve by introducing the viewport meta tag?
Topic: Viewport & Mobile-Friendly Pages • 2 marks marks
Early mobile browsers (such as the iPhone's Safari) rendered web pages at a wide desktop width and then shrank them to fit the phone screen. This either wasted space or forced the user to zoom in to read anything. Apple provided the viewport meta tag to be added to the HTML so that developers could control this default behaviour and set how the page is laid out and scaled on the device.
-
What is the main purpose of the viewport meta tag on a mobile web page?
Topic: Viewport & Mobile-Friendly Pages • 3 marks marks
The main purpose of the viewport meta tag is to control how the page layout is displayed and scaled on mobile browsers. It tells the browser the intended width of the page (usually the device's own width) and the initial zoom level, so the page fits the mobile screen properly instead of appearing as a shrunken desktop page. Without it, mobile browsers assume a wide layout width, media queries respond to that wrong width, and users must pinch and zoom to read the content.
-
Name and explain any three settings that can be used inside the viewport meta tag.
Topic: Viewport & Mobile-Friendly Pages • 3 marks marks
Three common settings of the viewport meta tag are: 1. width: Controls the width of the layout viewport, e.g. width=device-width sets it equal to the device's screen width. 2. initial-scale: Sets the initial zoom level of the page when it is first loaded, e.g. initial-scale=1.0 opens the page at its natural (100%) size. 3. user-scalable: Controls whether the user is allowed to pinch-zoom the page (user-scalable=yes or no). Related settings maximum-scale and minimum-scale limit how far the user can zoom in or out. These settings together control the size, scaling and zooming behaviour of the page on a mobile device.
-
What is a media query? What two parts does it consist of?
Topic: Media Queries • 3 marks marks
A media query is a CSS3 technique used to apply styles only when certain conditions about the device or display are true, so the same page can be styled differently for different screens. It is written with the @media rule in CSS. A media query consists of two parts: 1. A media type, which describes the general type of device, such as screen, print or all. 2. An expression, which checks for certain conditions of a particular media feature, such as (max-width: 600px). Example: @media screen and (max-width: 600px) { ... } applies the enclosed styles only on screens that are 600px wide or less.
-
Write the general syntax of a media query and explain it with an example.
Topic: Media Queries • 3 marks marks
The general syntax of a media query is: @media mediatype and (media-feature: value) { CSS styles } For example: @media screen and (max-width: 768px) { body { font-size: 14px; } } Explanation: The @media rule begins the media query. "screen" is the media type (the target device is a screen). The expression (max-width: 768px) checks the width media feature. The styles inside the block are applied only when the condition is true — here, when the screen width is 768 pixels or less, the font size becomes 14px. On wider screens this block is ignored and the normal styles apply.
-
Which features of a device or display can be checked by media queries? Give any four with their purpose.
Topic: Media Queries • 3 marks marks
Media queries can check many media features, including: 1. width / height: The width and height of the viewport or device screen — the most commonly used features for responsive breakpoints. 2. min-width / max-width: Minimum and maximum width ranges, used to apply styles below or above a chosen screen size. 3. orientation: Whether the device is in portrait (taller than wide) or landscape (wider than tall) mode. 4. resolution: The pixel density/sharpness of the display, used for example to serve sharper images to high-density (retina) screens. Other checkable features include aspect-ratio and hover capability.
-
How can multiple conditions be combined in a single media query? Explain with an example.
Topic: Media Queries • 3 marks marks
Multiple conditions in a media query are combined with the keyword "and". All the combined conditions must be true at the same time for the styles to be applied. Example: @media screen and (min-width: 600px) and (max-width: 900px) { ... } — these styles apply only to screens whose width is between 600px and 900px. A comma can also be used between media queries to work as an "or": the styles apply if any one of the listed queries is true, e.g. @media print, screen and (max-width: 600px).
-
What are breakpoints in responsive web design? Why are they used?
Topic: Media Queries • 3 marks marks
Breakpoints are the screen widths at which a media query changes the layout of a responsive website. At a breakpoint, different CSS rules take effect — for example columns stack vertically, menus change, or font sizes adjust. They are used because one layout cannot suit every screen: content that looks good side by side on a wide desktop becomes cramped on a narrow phone. Common breakpoints separate phones, tablets and desktops (e.g. up to 600px, 601–1024px, above 1024px). By setting breakpoints, the designer controls how the design and its content behave as the site scales down or up with the browser or device.
-
Differentiate between a media type and a media feature in a media query.
Topic: Media Queries • 3 marks marks
A media type describes the general category of device for which the styles are intended. Examples are all, screen (computer/phone screens), print (printed pages and print preview) and speech (screen readers). It appears right after the @media rule. A media feature describes a specific characteristic of the device or display that is tested in an expression, such as width, height, orientation or resolution. Media features are written in parentheses, usually with a value to compare, e.g. (max-width: 600px). In short, the media type says what kind of device it is, while the media feature expression tests an exact condition of that device.
-
What is a fluid grid? How does it differ from a fixed layout?
Topic: Fluid Layouts, Flexbox & Reflow • 3 marks marks
A fluid grid is a layout system in which the page is divided into columns and all measurements — widths, margins and spacing — are expressed in relative units such as percentages instead of fixed pixels. Because everything is proportional, the layout stretches or shrinks smoothly with the browser window or device screen. Responsive websites are built on a fluid grid. A fixed layout, in contrast, uses exact pixel widths that never change. On a screen smaller than the designed width it overflows and forces horizontal scrolling; on a much larger screen it leaves wasted empty space on the sides.
-
What is meant by the reflow of a web page? Which CSS tool makes reflow easier, and why?
Topic: Fluid Layouts, Flexbox & Reflow • 3 marks marks
Reflow is the process in which the browser recalculates the positions and sizes (geometry) of the elements of a page when the layout or display changes — for example when the window is resized, the device is rotated, or styles change. During reflow the browser works out again where every element should be placed and how big it should be. The CSS tool that makes reflow easier is Flexbox (the flexible box layout). Flexbox automatically distributes space among items in a container and re-arranges them as the available space grows or shrinks, so elements adjust smoothly during reflow instead of overlapping or overflowing.
-
What is Flexbox in CSS? State its main advantages in responsive layouts.
Topic: Fluid Layouts, Flexbox & Reflow • 3 marks marks
Flexbox (Flexible Box Layout) is a CSS3 layout model that arranges items in a container in one direction — a row or a column — and automatically distributes the available space among them. Items can grow, shrink and wrap according to the space available. Advantages in responsive layouts: (1) It makes reflow easier, because items re-arrange themselves when the screen size changes. (2) It removes the need for floats and fixed widths for simple one-dimensional layouts. (3) Alignment and spacing of items (including centering) become simple, so the same layout behaves predictably on phones, tablets and desktops.
-
How can images be made flexible so that they scale within a responsive layout?
Topic: Fluid Layouts, Flexbox & Reflow • 2 marks marks
Images are made flexible by setting their maximum width relative to their container instead of a fixed pixel width. The commonly used CSS is: img { max-width: 100%; height: auto; } With max-width: 100%, the image never becomes wider than its containing element: it shrinks on small screens instead of overflowing, and height: auto keeps its proportions correct. On larger screens it displays at its natural size.
-
Explain the CSS box model. Why is it important in responsive design?
Topic: Fluid Layouts, Flexbox & Reflow • 3 marks marks
The CSS box model describes every HTML element as a rectangular box made of four parts, from inside out: 1. Content — the actual text or image of the element. 2. Padding — the space between the content and the border. 3. Border — the line surrounding the padding and content. 4. Margin — the space outside the border, separating the element from other elements. It is important in responsive design because the total width of an element is the sum of all these parts. If padding and borders are not accounted for, percentage-based (fluid) widths can overflow their containers on small screens. The box model is one of the CSS3 features that ensure elements behave predictably when the layout must accommodate different display devices.
-
What does CSS stand for? What is the role of CSS in web development for mobile devices?
Topic: CSS Basics & Mobile Websites • 2 marks marks
CSS stands for Cascading Style Sheets. CSS controls the presentation of a web page — layout, colours, fonts, spacing and positioning — separately from the HTML content. For mobile devices its role is essential: through features such as media queries, Flexbox and the box model, CSS makes the same page adapt its layout and appearance to small phone screens, tablets and desktops, which is the basis of responsive web design.
-
Why is WordPress configured to give a totally different version of a website to phones?
Topic: CSS Basics & Mobile Websites • 3 marks marks
WordPress is configured to give a totally different version of a website to phones so that the content fits and works properly on small phone screens. A desktop version assumes a wide screen, a mouse and fast connections; on a phone it would appear shrunken, require zooming, and its menus and buttons would be hard to use with touch. The phone version presents the same content in a layout designed for the small screen — readable text, touch-friendly navigation and faster loading — so that the site complies with the mobile user's expectations.
-
State any five characteristics of a good mobile-friendly website.
Topic: CSS Basics & Mobile Websites • 3 marks marks
Five characteristics of a good mobile-friendly website are: 1. The viewport is set correctly, so the page fits the device's screen width without zooming. 2. The layout is responsive/fluid — it adjusts to different screen sizes and orientations. 3. Text is readable on a small screen without pinch-zooming. 4. Buttons and links are large enough and spaced for touch use. 5. Pages load quickly and content complies with the user's expectations — the important information is easy to find and use on the phone.
-
What problems does a user face when a desktop-only (non-responsive) website is opened on a mobile phone?
Topic: CSS Basics & Mobile Websites • 3 marks marks
When a desktop-only website is opened on a phone, the mobile browser renders the wide desktop layout and shrinks it to fit the small screen. The user faces these problems: 1. Wasted space or a shrunken page: text and images become too small to read. 2. Forced zooming: the user must repeatedly pinch and zoom to read content and tap links. 3. Horizontal scrolling: fixed-width content overflows the screen, so the user must scroll sideways as well as vertically. 4. Difficult interaction: small links and buttons designed for a mouse are hard to tap accurately with a finger. These problems are solved by setting the viewport and using responsive design techniques such as fluid grids and media queries.
-
Name and explain any three CSS3 features that ensure web page elements behave predictably when the layout must accommodate different display devices.
Topic: CSS Basics & Mobile Websites • 5 marks marks
Three such CSS3 features are: 1. Media Queries: They check the media type and features of the device (such as width and orientation) through expressions, and apply different styles for different conditions. This lets one page present suitable layouts for phones, tablets and desktops. 2. Flexbox (Flexible Box Layout): It arranges items in a container and automatically distributes space among them, making reflow easier. Elements resize and re-arrange predictably as the display changes size. 3. Box Model: It defines every element as content surrounded by padding, border and margin. Because sizes are calculated in a standard, predictable way, designers can use relative (percentage) widths confidently in fluid layouts for different devices. Together, these features make a page's behaviour consistent and predictable across display devices of all sizes.