Search code examples
cssplaceholderinputbox

Add text inside an inputbox using CSS


I cannot edit the html code, is the question below possible using only "CSS" code? How do you add a text just like a placeholder or something to an inputbox?

Here's the input text box code:

<input id="isn_email_address" type="text" name="user" size="40" maxlenth="90">

Solution

  • You can't set placeholders using CSS for all browsers. The only browser that supports it at the moment is webkit.

    Using jQuery you can achieve this : Working DEMO

    Note : you will need latest jquery library you can download from here jQuery Library

    Try this code :-

    <head>
    
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    
    <script type = "text/javascript">
    
            $(document).ready(function()
            {
    
                $('#isn_email_address').attr("placeholder", "Type your text here");    
    
            });
    
        </script>
    
    
    
    </head>