Skip to content

Courses / HTML5 Mastery: Complete Beginner to Advanced Course / HTML Comments & Characters

689 people viewed this

HTML Comments & Characters

  1. They are exactly the same thing
  2. A code point identifies a character, while UTF-8 encodes Unicode code points as bytes
  3. UTF-8 is a CSS selector
  4. 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?

  1. Comments always execute as JavaScript
  2. Comments are encrypted automatically
  3. Users can inspect the HTML source and discover the comment contents
  4. 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?

  1. Assign the input directly to innerHTML without validation
  2. Use textContent when the input should be displayed as text
  3. Place the input in an HTML comment
  4. 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?

  1. A CSS animation technique
  2. A type of HTML comment
  3. Garbled text caused by incorrect character-encoding interpretation
  4. 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.

Rate this course

5.0 · 1 rating

Stars show on this course. Your written note stays private.

Your stars