Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

HTML & CSS Align placeholder text in text field

Hello! I have put in custom code to my Shopify website. It's a field for Gift Messages, with the following placeholder text:
"To:
Message:
From:"

At the moment, the text isn't aligning to the left.
"To" is aligned to the left, but "Message & From" are indented quite significantly. I can't workout why my code is making this happen. Please help!!!!

You can see how it's displaying here (scroll down to gift message):
https://www.giftfox.com.au/products/neoprene-picnic-blankets

This is the code:

HTML:
{% if product.tags contains "message" %}
  <p class="line-item-property__field">
     <label for="gift-message">Gift Message</label>
     <textarea id="gift-message" name="properties[Gift Message]" style="width: 800px; text-align:left "placeholder= "To:

                                                                                                Message:

                                                                                                From:">
     </textarea>
  </p>
{% endif %}
 
Last edited by a moderator:
Solution
Hey Kirsten!

So what you need is this fancy fella &#10; this will essentially force a line-break which will cause the placeholder text to look something like:

Code:
To:
Message:
From:

So when &#10; is used it's to signal a line break which will move anything after it to the next line.

Here's what it looks like in your code:

HTML:
{% if product.tags contains "message" %}
  <p class="line-item-property__field">
     <label for="gift-message">Gift Message</label>
     <textarea id="gift-message" name="properties[Gift Message]" style="width: 800px; text-align:left "placeholder= "To:&#10;Message:&#10;From:">
     </textarea>
  </p>
{% endif %}

I have tested this on the Shopify platform and this was the result:

Screen Shot 2021-06-01 at 9.29.20 PM.png
Hey Kirsten!

So what you need is this fancy fella &#10; this will essentially force a line-break which will cause the placeholder text to look something like:

Code:
To:
Message:
From:

So when &#10; is used it's to signal a line break which will move anything after it to the next line.

Here's what it looks like in your code:

HTML:
{% if product.tags contains "message" %}
  <p class="line-item-property__field">
     <label for="gift-message">Gift Message</label>
     <textarea id="gift-message" name="properties[Gift Message]" style="width: 800px; text-align:left "placeholder= "To:&#10;Message:&#10;From:">
     </textarea>
  </p>
{% endif %}

I have tested this on the Shopify platform and this was the result:

Screen Shot 2021-06-01 at 9.29.20 PM.png
 
Solution
Hey Kirsten!

So what you need is this fancy fella &#10; this will essentially force a line-break which will cause the placeholder text to look something like:

Code:
To:
Message:
From:

So when &#10; is used it's to signal a line break which will move anything after it to the next line.

Here's what it looks like in your code:

HTML:
{% if product.tags contains "message" %}
  <p class="line-item-property__field">
     <label for="gift-message">Gift Message</label>
     <textarea id="gift-message" name="properties[Gift Message]" style="width: 800px; text-align:left "placeholder= "To:&#10;Message:&#10;From:">
     </textarea>
  </p>
{% endif %}

I have tested this on the Shopify platform and this was the result:

View attachment 921
Oh you are a legend, thank you so much! 😊
 

Latest posts

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom