Search code examples
htmlcssbuttonunderline

How to access the first word in a button text


here is my code

<button class="mcnTextContent"  type="button" style="text-decoration:underline">Click here to Reactivate your account before Feb. 1, 2016 for FREE</button>

I want to make first word (Click) only underlined . Can anyone please help me to figure that out.

Thanks


Solution

  • You can wrap the word Click in a styled span like so

    <button class="mcnTextContent"  type="button"><span style="text-decoration:underline">Click</span> here to Reactivate your account before Feb. 1, 2016 for FREE</button>
    

    Original Fiddle

    I also recommend not using in-line styling, so here it is without in-line css

    CSS

    #underline{
        text-decoration:underline;
    }
    

    HTML

    <button class="mcnTextContent"  type="button">
        <span id="underline">Click</span> here to Reactivate your account beforeFeb. 1, 2016 for FREE
    </button>
    

    Updated Fiddle