Docsity

HTML5 Coding Essentials Practice Exam: Test Your Knowledge, Exams of Technology

Toggle sidebar
bg1
HTML5 Coding Essentials and Best Practices
Certificate Practice Exam
**Question 1.** Which DOCTYPE declaration triggers standards mode in HTML5?
A) `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">`
B) `<!DOCTYPE html>`
C) `<!DOCTYPE HTML5>`
D) `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">`
Answer: B
Explanation: `<!DOCTYPE html>` is the simplified, case‑insensitive declaration that tells
browsers to render the page in standards mode for HTML5.
**Question 2.** What is the correct way to declare UTF‑8 character encoding in an HTML5
document?
A) `<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">`
B) `<meta charset="UTF-8">`
C) `<meta name="charset" content="UTF-8">`
D) `<meta http-equiv="charset" content="UTF-8">`
Answer: B
Explanation: HTML5 introduced the shorter `<meta charset="UTF-8">` element for declaring the
document’s character encoding.
**Question 3.** Which element is *not* considered a semantic container for page layout in
HTML5?
A) `<header>`
B) `<section>`
C) `<div>`
D) `<aside>`
Answer: C
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58

Partial preview of the text

Download HTML5 Coding Essentials Practice Exam: Test Your Knowledge and more Exams Technology in PDF only on Docsity!

Certificate Practice Exam

Question 1. Which DOCTYPE declaration triggers standards mode in HTML5? A) B) C) D) Answer: B Explanation: is the simplified, case‑insensitive declaration that tells browsers to render the page in standards mode for HTML5. **Question 2.** What is the correct way to declare UTF‑8 character encoding in an HTML document? A) B) C) D) Answer: B Explanation: HTML5 introduced the shorter element for declaring the document’s character encoding. Question 3. Which element is not considered a semantic container for page layout in HTML5? A) B) C) D) Answer: C

Certificate Practice Exam

Explanation: provides no semantic meaning; it is a generic block‑level container, whereas the others convey specific structural roles. **Question 4.** In a properly structured HTML5 page, which element should appear *once* and contain the main content of the document? A) B) C) D) Answer: C Explanation: The element represents the dominant content of the and should appear only once per page. **Question 5.** Which heading level is appropriate for a title inside an that already resides within a with an? A) B) C) D) Answer: C Explanation: Headings should reflect document hierarchy. If the section uses , the article’s title should be a lower level, such as. Question 6. Which pair of elements is used to associate a caption with an image or illustration? A) and B) and

Certificate Practice Exam

A) class B) style C) data-* D) title Answer: C Explanation: The data-* attribute pattern allows embedding custom, non‑semantic data that can be accessed via JavaScript. Question 10. What does the autocomplete attribute on a control? A) Whether the browser should suggest previously entered values for the form’s fields. B) Whether the form is submitted automatically after a timeout. C) Whether the form validates automatically on input. D) Whether the form can be submitted via the Enter key. Answer: A Explanation: `autocomplete="on"` or `"off"` tells the browser if it may store and suggest prior user inputs for the form’s controls. **Question 11.** Which HTML5 element is designed specifically for embedding an external video file? A) B) C) D) Answer: C Explanation: is the native HTML5 element for embedding video content with built‑in controls.

Certificate Practice Exam

Question 12. To provide fallback content for browsers that do not support , which element can be placed inside? A) B) C) D) Text or other HTML (fallback) Answer: D Explanation: Any content placed between the opening and closing tags is displayed as fallback if the element is unsupported. Question 13. Which attribute on the element specifies the MIME type of the media file? A) `src` B) `type` C) `media` D) `format` Answer: B Explanation: The `type` attribute declares the MIME type (e.g., `video/mp4`) helping the browser decide if it can play the source. **Question 14.** Which attribute of the element is used to label a subtitle track for user selection? A) src B) kind C) srclang D) label

Certificate Practice Exam

C) D) Answer: B Explanation: creates an inline frame that can load another HTML document. **Question 18.** When embedding an SVG file using the tag, which attribute must be present to ensure proper scaling? A) width only B) height only C) Both width and height or CSS max-width:100% D) viewBox attribute inside the SVG file itself Answer: C Explanation: The element respects its own `width`/`height` or CSS sizing; the SVG’s internal `viewBox` enables scaling but the outer element must define dimensions or responsive CSS. **Question 19.** Which input type automatically validates that the entered value conforms to an e‑mail address format? A) `type="text"` with pattern attribute B) `type="email"` C) `type="url"` D) `type="search"` Answer: B Explanation: `type="email"` triggers built‑in validation for the general email address syntax. **Question 20.** Which attribute makes an field mandatory before form submission?

Certificate Practice Exam

A) required B) autofocus C) novalidate D) placeholder Answer: A Explanation: The required attribute forces the browser to check that the field is not empty before allowing submission. Question 21. Which attribute on an sets the smallest permissible value? A) `min` B) `step` C) `max` D) `range` Answer: A Explanation: `min` defines the lower bound for numeric inputs; `max` defines the upper bound. **Question 22.** What does the `list` attribute on an element reference? A) An external CSS stylesheet. B) A element that provides autocomplete options. C) A element for dropdown choices. D) A JavaScript array. Answer: B Explanation: list="mylist" links the input to a `` which offers predefined suggestions.

Certificate Practice Exam

Explanation: setCustomValidity(message) assigns a custom error string that will be displayed when the element is invalid. Question 26. Which attribute on the `` element defines its drawing surface width in pixels? A) style="width:..." B) width C) data-width D) size Answer: B Explanation: The width attribute (not CSS) sets the internal pixel dimensions of the canvas; similarly, height sets the height. Question 27. To obtain a 2‑D drawing context from a canvas element, which JavaScript call is used? A) canvas.getContext('2d') B) canvas.context2d() C) canvas.get2DContext() D) canvas.createContext('2d') Answer: A Explanation: getContext('2d') returns the rendering context object for 2‑D drawing operations. Question 28. Which canvas method clears a rectangular area, making it fully transparent? A) clearRect(x, y, w, h) B) eraseRect(x, y, w, h) C) fillRect(x, y, w, h) with transparent color

Certificate Practice Exam

D) resetRect(x, y, w, h) Answer: A Explanation: clearRect removes any existing drawing in the specified rectangle, restoring the default transparent state. Question 29. Which sequence of canvas commands correctly draws a closed triangle? A) ctx.beginPath(); ctx.moveTo(10,10); ctx.lineTo(50,10); ctx.lineTo(30,40); ctx.closePath(); ctx.stroke(); B) ctx.moveTo(10,10); ctx.lineTo(50,10); ctx.lineTo(30,40); ctx.stroke(); C) ctx.beginPath(); ctx.lineTo(10,10); ctx.lineTo(50,10); ctx.lineTo(30,40); ctx.stroke(); D) ctx.beginPath(); ctx.arc(30,20,20,0,Math.PI*2); ctx.fill(); Answer: A Explanation: beginPath starts a new path, moveTo sets the first vertex, lineTo adds edges, closePath links back to the start, and stroke renders the outline. Question 30. Which canvas method draws a quadratic Bézier curve? A) quadraticCurveTo(cp1x, cp1y, x, y) B) bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) C) arcTo(x1, y1, x2, y2, radius) D) curveTo(cpX, cpY, x, y) Answer: A Explanation: quadraticCurveTo creates a curve defined by one control point and an end point. Question 31. Which canvas method creates a linear gradient? A) ctx.createLinearGradient(x0, y0, x1, y1) B) ctx.createRadialGradient(x0, y0, r0, x1, y1, r1)

Certificate Practice Exam

A) watchPosition() B) trackPosition() C) monitorLocation() D) observePosition() Answer: A Explanation: watchPosition registers a handler that receives updates whenever the device’s position changes. Question 35. What must a web page obtain before accessing the Geolocation API in most browsers? A) A valid SSL certificate. B) User’s explicit permission. C) An API key from Google. D) A cookie named “geo”. Answer: B Explanation: Browsers require the user to grant permission each time a page requests location data for privacy reasons. Question 36. Which storage object persists data even after the browser tab is closed? A) sessionStorage B) localStorage C) cookieStorage D) tempStorage Answer: B Explanation: localStorage retains key/value pairs across sessions until explicitly cleared.

Certificate Practice Exam

Question 37. Which method removes a specific item from localStorage? A) localStorage.deleteItem(key) B) localStorage.removeItem(key) C) localStorage.clearItem(key) D) localStorage.unset(key) Answer: B Explanation: removeItem deletes the entry identified by key from the storage. Question 38. What is the typical size limit for data stored in localStorage per origin in most modern browsers? A) 5 KB B) 5 MB C) 50 MB D) Unlimited Answer: B Explanation: Most browsers enforce a limit around 5 MB per origin for localStorage. Question 39. Which attribute makes an element draggable in HTML5? A) draggable="true" B) drag="enabled" C) movable="yes" D) dragable="true" Answer: A Explanation: Setting draggable="true" enables the native drag‑and‑drop mechanism for that element.

Certificate Practice Exam

Explanation: The presence of novalidate tells the browser to skip built‑in validation when the form is submitted. Question 43. Which element is used to provide a fallback text for browsers that do not support the element? A) B) C) Text placed inside the tags D) Answer: C Explanation: Any content placed between and is displayed if the element is unsupported. **Question 44.** Which JavaScript API allows drawing of vector graphics without a canvas element? A) WebGL B) SVG DOM C) Canvas 2D API D) WebGPU Answer: B Explanation: Scalable Vector Graphics (SVG) is an XML‑based vector format that can be manipulated directly via the DOM, independent of. Question 45. Which attribute of the `` element indicates that the browser should preload only metadata? A) preload="metadata" B) preload="none"

Certificate Practice Exam

C) preload="auto" D) preload="partial" Answer: A Explanation: preload="metadata" tells the browser to fetch only the file’s metadata (duration, dimensions) without downloading the whole media. Question 46. Which property of a element returns the current playback position in seconds? A) `currentTime` B) `playbackTime` C) `time` D) `position` Answer: A Explanation: The `currentTime` property reflects the elapsed playback time and can be set programmatically. **Question 47.** Which JavaScript method pauses a playing media element? A) `pause()` B) `stop()` C) `halt()` D) `suspend()` Answer: A Explanation: Both and elements expose a `pause()` method to halt playback. **Question 48.** Which attribute on a element specifies the language of the track’s text?

Certificate Practice Exam

Question 51. Which attribute on a provides a caption for the grouped controls? A) `legend` B) element inside the C) `title` D) `caption` Answer: B Explanation: The element, placed as the first child of , defines the group's caption. **Question 52.** Which attribute on an element specifies a regular expression that the value must match? A) pattern B) regex C) format D) match Answer: A Explanation: pattern holds a JavaScript‑compatible regular expression for client‑side validation. Question 53. Which attribute on an `` provides a default color value? A) value (e.g., value="#ff0000" ) B) default C) color D) preset Answer: A

Certificate Practice Exam

Explanation: The value attribute sets the initial selected color in hexadecimal notation. Question 54. Which method of the File interface returns the size of a selected file in bytes? A) file.size (property) B) file.getSize() C) file.length D) file.bytes Answer: A Explanation: size is a read‑only property of the File object indicating its byte length. Question 55. Which event fires when a file is dropped onto a valid drop target? A) drop B) dragdrop C) filedrop D) ondrop Answer: A Explanation: The drop event is dispatched on the target element when the dragged data is released. Question 56. Which property of a Worker object is used to send data to the worker thread? A) postMessage() method B) send() method C) transfer() method D) emit() method