- They are exactly the same thing
- A code point identifies a character, while UTF-8 encodes Unicode code points as bytes
- UTF-8 is a CSS selector
- A code point is always exactly one byte long
Correct answer: B
- A — Incorrect: Code points and encodings describe different concepts.
- B — Correct: Unicode identifies code points, while UTF-8 represents Unicode text using one to four bytes per code point.
- C — Incorrect: UTF-8 is a character encoding, not a CSS selector.
- D — Incorrect: A Unicode code point is a numeric value, not a byte; UTF-8 uses a variable number of bytes.
Question 8: Why should you avoid putting passwords in HTML comments?
- Comments always execute as JavaScript
- Comments are encrypted automatically
- Users can inspect the HTML source and discover the comment contents
- HTML comments can only contain numbers
Correct answer: C
- A — Incorrect: HTML comments are not JavaScript code.
- B — Incorrect: HTML comments are not encrypted.
- C — Correct: Comments are delivered with the page source and can be inspected.
- D — Incorrect: Comments can contain ordinary text subject to the HTML comment syntax rules.
Question 9: Which is the safest simple way to display user-entered text in a DOM element?
- Assign the input directly to
innerHTMLwithout validation - Use
textContentwhen the input should be displayed as text - Place the input in an HTML comment
- Convert every character to uppercase
Correct answer: B
- A — Incorrect: Assigning untrusted strings to innerHTML can cause markup injection and cross-site scripting risks.
- B — Correct: textContent treats the supplied value as text rather than parsing it as HTML.
- C — Incorrect: Comments are not a safe output mechanism for user input or a security control.
- D — Incorrect: Changing letter case does not prevent HTML injection.
Question 10: What is mojibake?
- A CSS animation technique
- A type of HTML comment
- Garbled text caused by incorrect character-encoding interpretation
- A method for converting decimal numbers into hexadecimal
Correct answer: C
- A — Incorrect: CSS animations control visual changes over time.
- B — Incorrect: Mojibake is unrelated to HTML comment syntax.
- C — Correct: Mojibake occurs when encoded text is interpreted incorrectly, producing garbled characters.
- D — Incorrect: Numeric conversion is unrelated to this encoding problem.
17. Final Checklist
Before moving to Section 7, confirm that you can:
- Write HTML comments correctly and avoid nested comments.
- Use named character references such as
&,<, and©. - Use decimal and hexadecimal numeric character references.
- Display HTML markup as text inside code examples.
- Explain the difference between Unicode code points and UTF-8 bytes.
- Declare UTF-8 and verify that source files use the correct encoding.
- Display multilingual text and symbols correctly.
- Recognize and troubleshoot common encoding problems.
- Use textContent for ordinary user-provided text rather than inserting untrusted content as HTML.
Next section: Section 7 — Links, Absolute and Relative URLs, Paths and Navigation.
End of Section 6 — Codementrix HTML5 Mastery.