in5 Answers archive · asked 2022-04-28 · 1 answer

How to get rid of empty space in textarea.

textarea

Not sure if this is a how to or a bug. I have several blank TextFields in InDesign that I'm exporting. However, when I do so, there's an extra non-breaking space character that's always entered by default. This forces the textarea to have a space at the beginning when folks start typing.

I don't have any default text or anything in the boxes, but this is how it comes out.

<textarea required="required" data-id="28257" alt="Spare_Time 3" name="Spare_Time 3" id="item28257" class="pageItem ">&nbsp;</textarea>

I'm thinking this might be a bug, and I can probably work around it w/ a script, but want to make sure I'm not doing something wrong first.

in5 user · 2022-04-28 · 7,954 views

1 answer

I confirmed with Justin that the non-breaking space is intentional. He said that a non-breaking space is added to ensure that the tag is not reduced to remove a closing tag, e.g., <textarea />. He said that can sometimes cause problems (mostly with <div>s).

in5 team · 2022-04-29

Thanks @Myra,

Unfortunately, you can't just plop and &nbsp; in between textarea's closing an opening tags. It's correct that <textarea /> isn't correct, but:
<textarea></textarea> is.

<textarea>&nbsp;</textarea> puts a default space in every text area, which looks unprofessional especially when the text wraps. You won't see that on any textarea on the web.

I'm not sure what the magic is behind the scenes and why it can't output as <textarea></textarea> instead of <textarea />, but hopefully they can make this correction. For now, I'll go ahead and use javascript to clear the &nbsp;, but that's just another indication that this can be done.

in5 user · 2022-04-29

You make a good point. This will be resolved in v3.8.8 soon.

in5 team · 2022-05-02

Was this useful?