sanitizeId

Sanitizes a string for use as an HTML element id attribute:

  • Strips characters that are problematic in CSS selectors and URL fragments (spaces, quotes, angle brackets, etc.).

  • Ensures the result is not empty.

  • Ensures the result does not start with a digit (#86).

Return

a safe identifier string, possibly different from the original