How remove whitespace on field in twig?
It sounds to me that you have a template, probably field.html.twig that is adding this space. You can enable the twig debug to see which templates' files are used.

Also, I think it's better to test the value on node.field.value instead of content.field as it's done for the rendering only.

Note that the twig operators as {% for ... %} also add spaces, so you should add - as well in there for e.g.:

{%- for item in items %}
{{ item.content }}
{%  endfor -%}