Clean related links stylesheet for HTML

Use functions to reduce code duplication.