Jump to main content
Menu

Comments and Special Characters

HTML Comments

  • HTML comments are coded as:
    <!-- This is a comment -->
    
  • <!-- begins the comment
  • --> ends the comment
  • I recommend leaving at least one space between <!-- and -->, for improved readability and to avoid any parser issues.
  • Comments do not render on the page.
  • They are used for a variety of purposes:
    • Identifying the author of the code
    • Inserting reminders / "to do" items
    • Providing explanations for the current (or future) authors about something in the code
    • Troubleshooting rendering problems
  • When troubleshooting rendering problems:
    • Start by putting a large area of the code inside comments and ensuring that the rendering problem is gone.
    • Systematically move the comments to smaller and smaller segments of code, each time checking to see if the rendering problem has returned.
    • Through this process you should eventually isolate the code that is causing the rendering issue.
  • Multiple sets of comments can be included in a document - there is no limit.

Special Characters

  • These are characters that often cannot be entered via the keyboard as-is, because the character does not exist on your keyboard. Instead they have a special code that must be entered.
  • View a list of special characters
  • Special characters have a numerical value that identifies them as well as a series of characters that identifies them.
  • One of the most commonly used special characters is &nbsp; which creates a non-breaking space. It can also be coded as &#160;
    • Each non-breaking space renders as a narrow empty space.
    • These prevent the content being joined together from wrapping to new lines when the window is too small (assuming there are no gaps / regular spaces mixed in, which would permit wrapping).
    • I recommend using these sparingly.
  • It is not necessary to encode quotes as &quot; (or &#34;) in your page content, however you might choose to do this if you prefer its rendering/appearance (the key on your keyboard used for quotes is probably meant to designate inches and renders somewhat differently). These would be quotes in the visible text on the page, not in your tags.
  • To prevent confusion with tags, content that involves greater-than signs (&gt; or &#62;) or less-than signs (&lt; or &#60;) should have those characters encoded; otherwise they could be confused as the start or end of tags.
  • Important: Always start a special character with & and end it with a semicolon.