Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Span Tag

  • 14-08-2018 9:01pm
    #1
    Registered Users, Registered Users 2 Posts: 8,423 ✭✭✭


    I'm trying to use the "Span Tag" in a line of HTML code but I can't get it to do what I want.

    I want the Asterix in the line of code to appear RED while leaving the rest of the text default.

    The line of code:

    <input name="name" placeholder="Enter your name *" required / type="name">


    This line below works fine as a standalone line of code so how can I incorporate it into the line above in order to get the asterix to show red?

    <p><span style="color: red;">THE WORD YOU WANT RED</span></p>


    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



Comments

  • Registered Users, Registered Users 2 Posts: 6,284 ✭✭✭Talisman


    The simple answer is you can't. You can style the entire text across most browsers using vendor-prefixed selectors.

    HTML:
    <input class="red-placeholder" name="name" placeholder="Enter your name *"
     required type="text">
    

    CSS:
    input[type="text"].red-placeholder::-webkit-input-placeholder,
    input[type="text"].red-placeholder::-moz-placeholder,
    input[type="text"].red-placeholder:-ms-input-placeholder {
      color: red;
      opacity: 1;
    }
    


  • Registered Users, Registered Users 2 Posts: 9,383 ✭✭✭S.M.B.


    You would normally find the red asterisk with or without text saying that's it's required outside the input box anyway.


  • Registered Users, Registered Users 2 Posts: 5,516 ✭✭✭Wheety


    S.M.B. wrote: »
    You would normally find the red asterisk with or without text saying that's it's required outside the input box anyway.
    This. I think the placeholder text is grayed out (as standard)? It's not meant to stand out too much.

    Usually you'd have the asterisk outside the box.


  • Registered Users, Registered Users 2 Posts: 895 ✭✭✭Dubba


    Have you seen this solution on stackoverflow? Basically creating your own placeholder element within an input, with span tags for the asterix.


  • Registered Users, Registered Users 2 Posts: 8,423 ✭✭✭Gadgetman496


    Dubba wrote: »
    Have you seen this solution on stackoverflow? Basically creating your own placeholder element within an input, with span tags for the asterix.


    That's exactly what I wanted to achieve but that solution is CSS and I have no idea how to use that in conjunction with the HTML form I'm using.

    The form I'm using is is a contact form from https://formspree.io/

    This is the HTML code:
    <form method="POST" action="https://formspree.io/YOUREMAILHERE"&gt;
    <input name="email" placeholder="Your email" type="email">
    <textarea name="message" placeholder="Your message"></textarea>
    <button type="submit">Send</button>
    </form>

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,284 ✭✭✭Talisman


    Normally you would use a label tag for each input and use CSS to style the markup.
    <form method="POST" action="https://formspree.io/YOUREMAILHERE">
        <div class="field">
            <label class="placeholder" for="email">
                Email Address <span class="red">*</span>
            </label>
            <input name="email" placeholder="Your email" required type="email">
        </div>
        <div class="field">
            <label class="placeholder" for="message">
                Message <span class="red">*</span>
            </label>
            <textarea name="message" placeholder="Your message"></textarea>
        </div>
        <div class="field">
            <button type="submit">Send</button>
        </div>
    </form>
    


  • Registered Users, Registered Users 2 Posts: 8,423 ✭✭✭Gadgetman496


    Talisman wrote: »
    Normally you would use a label tag for each input and use CSS to style the markup.
    <form method="POST" action="https://formspree.io/YOUREMAILHERE">
        <div class="field">
            <label class="placeholder" for="email">
                Email Address <span class="red">*</span>
            </label>
            <input name="email" placeholder="Your email" required type="email">
        </div>
        <div class="field">
            <label class="placeholder" for="message">
                Message <span class="red">*</span>
            </label>
            <textarea name="message" placeholder="Your message"></textarea>
        </div>
        <div class="field">
            <button type="submit">Send</button>
        </div>
    </form>
    

    Right now if I punch that form code into a web-page it returns this, so I'm guessing you mean that CSS code would clean that look up and format it differently on the page?


    6d5e901663.JPG


    I have no idea how to get this all together so I'm obviously living up to my post prefix of COLOR="DarkGreen"]n00b[/COLOR Ha Ha Ha!

    I think this is just outside my league and it would probably drive anyone willing to help crazy.

    I really do appreciate you guy's trying to get me to understand it a little better trough, so thanks to all who replied :)

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 895 ✭✭✭Dubba


    I think this is just outside my league

    I think it'd be worth taking a free online course in web dev because your not at the stage yet that googling for a solution to your issues would be any use. Realistically, you would need to know the basics off html and css for what your trying to do, it's not too complicated and you should be able to pick it up pretty fast.

    If that doesn't interest you. Have a look at w3schools.com CSS Forms, for an idea of how to style forms.


  • Registered Users, Registered Users 2 Posts: 6,284 ✭✭✭Talisman


    Right now if I punch that form code into a web-page it returns this, so I'm guessing you mean that CSS code would clean that look up and format it differently on the page?

    6d5e901663.JPG

    I have no idea how to get this all together so I'm obviously living up to my post prefix of COLOR="DarkGreen"]n00b[/COLOR Ha Ha Ha!

    I think this is just outside my league and it would probably drive anyone willing to help crazy.

    I really do appreciate you guy's trying to get me to understand it a little better trough, so thanks to all who replied :)
    The best approach to learning HTML & CSS would be to followed a structured course. It's far too easy to search online and pick up bad practices. I would recommend signing up to Codecademy and working through their Web Development track.


  • Registered Users, Registered Users 2 Posts: 6,284 ✭✭✭Talisman


    Another great resource for any aspiring web developer is the Frontend Masters sponsored Front-End Developer Handbook. It's updated annually so the resources listed are always up to date.


  • Advertisement
Advertisement