MCQs / Computer Science / HTML5 for Mobiles

HTML5 for Mobiles MCQs — Computer Science

39 multiple-choice questions on HTML5 for Mobiles from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.

1. Which input type displays a slider?

  1. slider
  2. range
  3. number
  4. scroll

Answer: B) range

Explanation: type="range" renders a slider control.

Discuss this question

2. Connecting label for="email" to input id="email" helps mobile users because:

  1. It validates the email
  2. It hides the field
  3. Tapping the label focuses the field and screen readers announce it
  4. It changes the keyboard

Answer: C) Tapping the label focuses the field and screen readers announce it

Explanation: Associated labels enlarge the tap area and improve accessibility.

Discuss this question

3. Which HTML5 element should contain the main navigation links?

  1. aside
  2. section
  3. nav
  4. header

Answer: C) nav

Explanation: The nav element represents a block of navigation links.

Discuss this question

4. Which is a major advantage of HTML5 mobile web apps over native apps?

  1. Listed automatically in the App Store
  2. Full Bluetooth access
  3. One code base runs on all platforms and updates instantly
  4. Always better performance

Answer: C) One code base runs on all platforms and updates instantly

Explanation: Web apps run anywhere with a browser and update on the server.

Discuss this question

5. The srcset attribute of an img element is used to:

  1. Add a caption
  2. Lazy-load scripts
  3. Offer images of different resolutions so the browser picks the best one
  4. Set the alt text

Answer: C) Offer images of different resolutions so the browser picks the best one

Explanation: srcset lists alternative image files and widths for responsive images.

Discuss this question

6. HTML5 pages declare the document type with:

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. <doctype mobile
  3. <!DOCTYPE html
  4. <html version="5"

Answer: C) <!DOCTYPE html

Explanation: HTML5 uses the short doctype <!DOCTYPE html.

Discuss this question

7. Which is NOT a requirement for a PWA?

  1. A web app manifest
  2. HTTPS
  3. Approval from Google Play
  4. A service worker

Answer: C) Approval from Google Play

Explanation: PWAs do not need store approval.

Discuss this question

8. Setting user-scalable=no in the viewport tag is discouraged because:

  1. It slows the page
  2. It breaks media queries
  3. It disables JavaScript
  4. It prevents users with poor eyesight from zooming (accessibility)

Answer: D) It prevents users with poor eyesight from zooming (accessibility)

Explanation: Disabling zoom harms accessibility.

Discuss this question

9. Which CSS rule makes images shrink to fit small screens?

  1. img float: left;
  2. img width: 2000px;
  3. img max-width: 100%; height: auto;
  4. img display: none;

Answer: C) img max-width: 100%; height: auto;

Explanation: max-width 100% keeps images within their container while height auto keeps the ratio.

Discuss this question

10. Web Storage typically allows about how much data per site?

  1. 5 MB
  2. Unlimited
  3. 4 KB
  4. 5 GB

Answer: A) 5 MB

Explanation: Most browsers allow around 5 MB for localStorage per origin.

Discuss this question

11. Which media query applies styles only when the device is turned sideways?

  1. @media (orientation: landscape)
  2. @media (min-width: 0)
  3. @media print
  4. @media (hover: hover)

Answer: A) @media (orientation: landscape)

Explanation: The orientation feature detects portrait or landscape.

Discuss this question

12. Which input type opens a native calendar picker?

  1. calendar
  2. time-picker
  3. range
  4. date

Answer: D) date

Explanation: type="date" displays the browser's native date picker.

Discuss this question

13. Which API makes a phone vibrate from a web page?

  1. device.buzz()
  2. navigator.motion()
  3. navigator.vibrate()
  4. window.shake()

Answer: C) navigator.vibrate()

Explanation: The Vibration API uses navigator.vibrate(milliseconds).

Discuss this question

14. Without the viewport tag, mobile browsers typically render the page as if it were about:

  1. 100 px wide
  2. 980 px wide and then zoom out
  3. 320 px wide
  4. 1920 px wide

Answer: B) 980 px wide and then zoom out

Explanation: Mobile browsers assume a desktop-like width of about 980 px and shrink the page.

Discuss this question

15. Which meta tag makes a page use the real device width on phones?

  1. <meta http-equiv="mobile"
  2. <meta name="screen" content="mobile"
  3. <meta name="width" content="100%"
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0"

Answer: D) <meta name="viewport" content="width=device-width, initial-scale=1.0"

Explanation: The viewport meta tag sets the layout viewport to the device width with no initial zoom.

Discuss this question

16. Which three technologies together build a mobile web app?

  1. Swift, UIKit and Xcode
  2. Kotlin, XML and Gradle
  3. HTML5, CSS3 and JavaScript
  4. C, C++ and Assembly

Answer: C) HTML5, CSS3 and JavaScript

Explanation: HTML structures, CSS styles and JavaScript adds behaviour.

Discuss this question

17. The three ingredients of responsive web design are:

  1. Fluid grids, flexible images and media queries
  2. Frames, tables and Flash
  3. HTML, PHP and SQL
  4. Cookies, sessions and caching

Answer: A) Fluid grids, flexible images and media queries

Explanation: Ethan Marcotte defined RWD as fluid grids, flexible images and media queries.

Discuss this question

18. Which HTML5 feature replaced the need for the Flash plug-in for media?

  1. canvas element
  2. Web Storage
  3. nav element
  4. Native audio and video elements

Answer: D) Native audio and video elements

Explanation: The audio and video elements play media natively without plug-ins.

Discuss this question

19. Which input type shows a keyboard with the @ symbol and validates the format?

  1. email
  2. search
  3. url
  4. text

Answer: A) email

Explanation: type="email" shows an email keyboard and validates the address format.

Discuss this question

20. Which shortcut opens device emulation mode in Chrome DevTools?

  1. Ctrl + D
  2. Ctrl + Shift + M
  3. Ctrl + P
  4. F5

Answer: B) Ctrl + Shift + M

Explanation: Ctrl + Shift + M toggles the device toolbar in DevTools.

Discuss this question

21. The Geolocation API works only on pages served over:

  1. HTTPS (secure context)
  2. Local files only
  3. HTTP without encryption
  4. FTP

Answer: A) HTTPS (secure context)

Explanation: Browsers require a secure context (HTTPS) for geolocation.

Discuss this question

22. For an Urdu web page, which attributes should be set on the html element?

  1. lang="pk" dir="up"
  2. charset="urdu"
  3. lang="en" dir="ltr"
  4. lang="ur" dir="rtl"

Answer: D) lang="ur" dir="rtl"

Explanation: Urdu is written right-to-left, so lang="ur" and dir="rtl" are used.

Discuss this question

23. The attribute capture="environment" on a file input:

  1. Captures GPS location
  2. Saves form data
  3. Opens the rear camera directly on mobile devices
  4. Records the screen

Answer: C) Opens the rear camera directly on mobile devices

Explanation: On phones it asks the browser to open the back camera for capturing an image.

Discuss this question

24. In a web app manifest, "display": "standalone" means the app:

  1. Opens in a new browser tab
  2. Prints automatically
  3. Runs only on desktop
  4. Opens without browser UI, like a native app

Answer: D) Opens without browser UI, like a native app

Explanation: standalone hides the browser address bar so it looks like an app.

Discuss this question

25. Which HTML5 element provides a drawing surface for JavaScript graphics and games?

  1. picture
  2. canvas
  3. figure
  4. svg-area

Answer: B) canvas

Explanation: canvas offers a bitmap drawing area controlled by JavaScript.

Discuss this question

Page 1 of 2 Next

Practise HTML5 for Mobiles MCQs

More Computer Science chapters